chore(crashtracking): harden multi thread ptrace collection#2216
Conversation
📚 Documentation Check Results📦
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 7ebd2b9 | Docs | Datadog PR Page | Give us feedback! |
🔒 Cargo Deny Results📦
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: edd03dc8f1
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: edd03dc8f1
ℹ️ 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".
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
BenchmarksComparisonBenchmark execution time: 2026-07-15 13:22:32 Comparing candidate commit 7ebd2b9 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.
|
| cpu_model | git_commit_sha | git_commit_date | git_branch |
|---|---|---|---|
| Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz | 7ebd2b9 | 1784121131 | gyuheon0h/multi-thread-collection-harden |
| scenario | metric | min | mean ± sd | median ± mad | p75 | p95 | p99 | max | peak_to_median_ratio | skewness | kurtosis | cv | sem | runs | sample_size |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| receiver_entry_point/report/2644 | execution_time | 3.344ms | 3.377ms ± 0.026ms | 3.368ms ± 0.013ms | 3.387ms | 3.428ms | 3.460ms | 3.472ms | 3.09% | 1.299 | 1.296 | 0.76% | 0.002ms | 1 | 200 |
| scenario | metric | 95% CI mean | Shapiro-Wilk pvalue | Ljung-Box pvalue (lag=1) | Dip test pvalue |
|---|---|---|---|---|---|
| receiver_entry_point/report/2644 | execution_time | [3.373ms; 3.380ms] or [-0.106%; +0.106%] | None | None | None |
Baseline
Baseline benchmark details
Group 1
| cpu_model | git_commit_sha | git_commit_date | git_branch |
|---|---|---|---|
| Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz | a10f667 | 1784074032 | main |
| scenario | metric | min | mean ± sd | median ± mad | p75 | p95 | p99 | max | peak_to_median_ratio | skewness | kurtosis | cv | sem | runs | sample_size |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| receiver_entry_point/report/2644 | execution_time | 3.339ms | 3.364ms ± 0.016ms | 3.360ms ± 0.008ms | 3.370ms | 3.393ms | 3.415ms | 3.425ms | 1.95% | 1.391 | 2.247 | 0.48% | 0.001ms | 1 | 200 |
| scenario | metric | 95% CI mean | Shapiro-Wilk pvalue | Ljung-Box pvalue (lag=1) | Dip test pvalue |
|---|---|---|---|---|---|
| receiver_entry_point/report/2644 | execution_time | [3.361ms; 3.366ms] or [-0.067%; +0.067%] | None | None | None |
d292c2f to
dc76d1f
Compare
39e3d72 to
39c9f0f
Compare
39c9f0f to
a87179c
Compare
a87179c to
78b3ebf
Compare
fe8db49 to
25d74f4
Compare
25d74f4 to
7ebd2b9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ebd2b92ea
ℹ️ 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".

PROF-15363
What does this PR do?
test_crash_tracking_multi_thread_collectionhas been failing ~10% of the time on CentOS 7 CI. The test spawns worker threads in spin loops, crashes, and validates that the receiver's ptrace-based collector captured stack frames for all threads. Failures showedct_worker_X stack should contain a frame for 'worker_fn_X' but got: []I built the CentOS 7 Docker image from
tools/docker/Dockerfile.centosand ran the test inside it. It passed 100/100 in isolation and 500/500 at full CPU. However, when I trottled the CPU (docker --cpus=0.5) I was able to reproduced the failure at ~10% rate.By adding some logging, I was able to see this
wait_for_stopexceeded the 50msSTOP_TIMEOUT_PER_THREADETIMEDOUTpath calleddetach_threadthen retriedPTRACE_SEIZEgotEPERMbecause the kernel hadn't fully processed the detachEPERMwas treated as permanent -> gave up -> 0 framesChanges
STOP_TIMEOUT_PER_THREAD: 50ms to 200ms; 50ms was too short under CPU contention. The thread genuinely couldn't be scheduled to enter ptrace-stop in time.wait_for_registers-- Changed from detach + returnETIMEDOUTtolet _ = wait_for_registers(...). libunwind usesPTRACE_GETREGSETwhich can succeed even whenPTRACE_PEEKUSERreturns zero. This avoids the detach re-attach cycle that triggeredEPERM.waitpiddrain after detach -- Addedwaitpid(tid, NULL, __WALL | WNOHANG)afterPTRACE_DETACHto consume pending kernel events, ensuring the thread is fully released before any retry can re-seize it.The retry-with-exponential-backoff mechanism was added in earlier iterations and remains in the final fix for additional strengthening
I modified
test.yamlto run the test 100x in CI: https://github.com/DataDog/libdatadog/actions/runs/29366237931/job/87198658036?pr=2216Prior to these changes, this test would consistently fail, but now, it does not.
Motivation
Too many flakes on these tests
Additional Notes
Anything else we should know when reviewing?
How to test the change?
Describe here in detail how the change can be validated.