fix(live-debugger): guard against NULL sidecar in diagnostics calls#3824
fix(live-debugger): guard against NULL sidecar in diagnostics calls#3824
Conversation
DDTRACE_G(sidecar) is NULL until ddtrace_sidecar_ensure_active() runs in RINIT. In minimal install environments the sidecar may not be initialized when live debugger diagnostics are sent. Use the global sidecar fallback (ddtrace_sidecar_for_signal) and skip the call if both are NULL.
There was a problem hiding this comment.
This points to a deeper problem.
This testsuite never should have DDTRACE_G(sidecar) == NULL. How does that happen?
We never should install debugger probes before initializing the sidecar. And we probably should also skip installing them if connecting to the sidecar failed.
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 8de240b | Docs | Datadog PR Page | Give us feedback! |
Benchmarks [ tracer ]Benchmark execution time: 2026-04-24 12:13:44 Comparing candidate commit 8de240b in PR branch Found 1 performance improvements and 2 performance regressions! Performance is the same for 191 metrics, 0 unstable metrics. scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache
scenario:SamplingRuleMatchingBench/benchRegexMatching3
scenario:SamplingRuleMatchingBench/benchRegexMatching4
|
Problem
The
min install testsCI job was failing with a crash caused by a NULL dereference inext/live_debugger.c. After commit6b55c3ee5introduced per-thread sidecar (DDTRACE_G(sidecar)), calls toddog_send_debugger_diagnostics()pass&DDTRACE_G(sidecar)without checking for NULL. In minimal install environments, the sidecar hasn't been initialized by the time live debugger diagnostics are sent.Fix
Add a NULL guard at each
ddog_send_debugger_diagnostics()call site inext/live_debugger.c. Useddtrace_sidecar_for_signal(the global fallback sidecar handle) when the per-thread sidecar is NULL, and skip the call entirely if both are NULL.Testing
The
min install testsjob runs with a stripped-down PHP environment where the sidecar isn't always initialized. This fix prevents the crash in that scenario.