Skip to content

fix(crashtracker): support socket based receiver for all thread collection#2080

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
mainfrom
gyuheon0h/PROF-14896-sidecar-all-threads-support
Jun 4, 2026
Merged

fix(crashtracker): support socket based receiver for all thread collection#2080
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
mainfrom
gyuheon0h/PROF-14896-sidecar-all-threads-support

Conversation

@gyuheon0h

@gyuheon0h gyuheon0h commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

In crash_handler.rs, PR_SET_PTRACER is only called when receiver.handle.pid is Some:

if let Some(receiver_pid) = receiver.handle.pid {
        unsafe {
            libc::prctl(libc::PR_SET_PTRACER, receiver_pid as libc::c_ulong);
        }
    }

PHP connects to a pre-existing sidecar process using a Unix socket (optional_unix_socket_filename).

In receiver_manager.rs, the from_socket() path creates a ProcessHandle with pid: None:

Ok(Self {
    handle: ProcessHandle::new(uds_fd, None),
})

If ptrace_scope=1, since pid is None, PR_SET_PTRACER is never called. The sidecar then cannot ptrace the crashed process's threads.

The fix is to resolve the peer process's PID using getsockopt(SO_PEERCRED) on the Unix socket fd, then call PR_SET_PTRACER with that PID.

Motivation

I noticed that all PHP crash reports (schema 1.7) have error.threads with 0 frames per thread. Thread names are present (ddprof_time, ddprof_upload), but stacks are empty with incomplete: false. This affects 100% of PHP crashes. Ruby and Python are unaffected.

Additional Notes

Anything else we should know when reviewing?

How to test the change?

Describe here in detail how the change can be validated.

gyuheon0h commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@gyuheon0h gyuheon0h changed the title Socket based receiver support fix(crashtracker): support socket based receiver for all thread collection Jun 4, 2026
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 4, 2026

Copy link
Copy Markdown

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

semver-check | detect-changes   View in Datadog   GitHub Actions

See error Couldn't find remote ref 'gyuheon0h/PROF-14896-incomplete-failed-attach'.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 13.33%
Overall Coverage: 73.53% (-0.08%)

Useful? React with 👍 / 👎

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

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

Summary by Rule

Rule Base Branch PR Branch Change

Annotation Counts by File

File Base Branch PR Branch Change

Annotation Stats by Crate

Crate Base Branch PR Branch Change
clippy-annotation-reporter 0 5 ⚠️ +5 (N/A)
datadog-ffe-ffi 0 1 ⚠️ +1 (N/A)
datadog-ipc 0 21 ⚠️ +21 (N/A)
datadog-live-debugger 0 6 ⚠️ +6 (N/A)
datadog-live-debugger-ffi 0 10 ⚠️ +10 (N/A)
datadog-profiling-replayer 0 4 ⚠️ +4 (N/A)
datadog-remote-config 0 3 ⚠️ +3 (N/A)
datadog-sidecar 0 57 ⚠️ +57 (N/A)
libdd-common 0 13 ⚠️ +13 (N/A)
libdd-common-ffi 0 12 ⚠️ +12 (N/A)
libdd-data-pipeline 0 5 ⚠️ +5 (N/A)
libdd-ddsketch 0 2 ⚠️ +2 (N/A)
libdd-dogstatsd-client 0 1 ⚠️ +1 (N/A)
libdd-profiling 0 13 ⚠️ +13 (N/A)
libdd-telemetry 0 20 ⚠️ +20 (N/A)
libdd-tinybytes 0 4 ⚠️ +4 (N/A)
libdd-trace-normalization 0 2 ⚠️ +2 (N/A)
libdd-trace-obfuscation 0 3 ⚠️ +3 (N/A)
libdd-trace-stats 0 1 ⚠️ +1 (N/A)
libdd-trace-utils 0 13 ⚠️ +13 (N/A)
Total 0 196 ⚠️ +196 (N/A)

About This Report

This report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality.

@codecov-commenter

codecov-commenter commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 13.33333% with 91 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.52%. Comparing base (582bee1) to head (04b8385).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2080      +/-   ##
==========================================
- Coverage   73.58%   73.52%   -0.07%     
==========================================
  Files         470      473       +3     
  Lines       78449    78551     +102     
==========================================
+ Hits        57729    57756      +27     
- Misses      20720    20795      +75     
Components Coverage Δ
libdd-crashtracker 65.31% <0.00%> (-0.17%) ⬇️
libdd-crashtracker-ffi 37.68% <ø> (ø)
libdd-agent-client 83.79% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 87.14% <ø> (ø)
libdd-data-pipeline-ffi 77.03% <ø> (ø)
libdd-common 79.93% <ø> (ø)
libdd-common-ffi 74.41% <ø> (ø)
libdd-telemetry 73.37% <ø> (ø)
libdd-telemetry-ffi 31.36% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.22% <ø> (+1.46%) ⬆️
libdd-profiling 81.68% <ø> (-0.02%) ⬇️
libdd-profiling-ffi 64.79% <ø> (ø)
libdd-sampling 97.41% <ø> (ø)
datadog-sidecar 35.99% <ø> (ø)
datdog-sidecar-ffi 15.89% <ø> (ø)
spawn-worker 48.86% <ø> (ø)
libdd-tinybytes 93.80% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.30% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 89.29% <ø> (ø)
libdd-tracer-flare 86.88% <ø> (ø)
libdd-log 74.83% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-14896-sidecar-all-threads-support branch 2 times, most recently from bd67302 to d0905ea Compare June 4, 2026 14:23
@gyuheon0h
gyuheon0h marked this pull request as ready for review June 4, 2026 14:54
@gyuheon0h
gyuheon0h requested review from a team as code owners June 4, 2026 14:54
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-14896-incomplete-failed-attach branch from 16d9598 to c7d067b Compare June 4, 2026 14:54
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-14896-sidecar-all-threads-support branch from d0905ea to 31474f7 Compare June 4, 2026 14:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 31474f7fe9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread bin_tests/tests/crashtracker_bin_test.rs Outdated

@gleocadie gleocadie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one comment but overall LGTM

Comment thread libdd-crashtracker/src/collector/crash_handler.rs
Base automatically changed from gyuheon0h/PROF-14896-incomplete-failed-attach to main June 4, 2026 15:33
@dd-octo-sts

dd-octo-sts Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 82.85 MB 82.84 MB -0% (-784 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.63 MB 7.63 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.25 MB 10.25 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 93.92 MB 93.92 MB -0% (-1008 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 24.53 MB 24.53 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 83.96 KB 83.96 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 178.05 MB 178.04 MB -0% (-8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 913.44 MB 913.44 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.02 MB 8.02 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 83.96 KB 83.96 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 23.75 MB 23.75 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 47.38 MB 47.38 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.25 MB 21.25 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 85.29 KB 85.29 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 181.97 MB 181.98 MB +0% (+8.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 906.06 MB 906.06 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.19 MB 6.19 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 85.29 KB 85.29 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 25.45 MB 25.45 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 45.03 MB 45.03 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 73.86 MB 73.86 MB -0% (-472 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.52 MB 8.52 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 89.27 MB 89.27 MB -0% (-592 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.35 MB 10.35 MB 0% (0 B) 👌

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit a97e1d4 into main Jun 4, 2026
131 of 135 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the gyuheon0h/PROF-14896-sidecar-all-threads-support branch June 4, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants