Skip to content

fix(live-debugger): guard against NULL sidecar in diagnostics calls#3824

Draft
Leiyks wants to merge 1 commit intomasterfrom
leiyks/fix-ci-live-debugger-null-sidecar
Draft

fix(live-debugger): guard against NULL sidecar in diagnostics calls#3824
Leiyks wants to merge 1 commit intomasterfrom
leiyks/fix-ci-live-debugger-null-sidecar

Conversation

@Leiyks
Copy link
Copy Markdown
Contributor

@Leiyks Leiyks commented Apr 24, 2026

Problem

The min install tests CI job was failing with a crash caused by a NULL dereference in ext/live_debugger.c. After commit 6b55c3ee5 introduced per-thread sidecar (DDTRACE_G(sidecar)), calls to ddog_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 in ext/live_debugger.c. Use ddtrace_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 tests job runs with a stripped-down PHP environment where the sidecar isn't always initialized. This fix prevents the crash in that scenario.

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.
Copy link
Copy Markdown
Collaborator

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 Bot commented Apr 24, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.64% (-0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8de240b | Docs | Datadog PR Page | Give us feedback!

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Apr 24, 2026

Benchmarks [ tracer ]

Benchmark execution time: 2026-04-24 12:13:44

Comparing candidate commit 8de240b in PR branch leiyks/fix-ci-live-debugger-null-sidecar with baseline commit b7eb412 in branch master.

Found 1 performance improvements and 2 performance regressions! Performance is the same for 191 metrics, 0 unstable metrics.

scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache

  • 🟩 execution_time [-6.807µs; -4.913µs] or [-5.947%; -4.293%]

scenario:SamplingRuleMatchingBench/benchRegexMatching3

  • 🟥 execution_time [+35.742ns; +91.858ns] or [+2.450%; +6.298%]

scenario:SamplingRuleMatchingBench/benchRegexMatching4

  • 🟥 execution_time [+29.433ns; +96.967ns] or [+2.005%; +6.605%]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants