test(profiling): suppress TSan false positive in fork death tests #21997
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 562 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.379
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #21997"
general
weight: 0.35
gyuheon0h
<!-- dd-meta {"pullId":"e5ea62b1-f454-4ef8-8f18-f556cd5e43d1","source":"chat","resourceId":"3791bbb8-f9f4-41e3-a2e7-a94b71e38e67","workflowId":"0938f146-e4ef-4e87-b9cb-dde01bbc3fe7","codeChangeId":"0938f146-e4ef-4e87-b9cb-dde01bbc3fe7","sourceType":"code_channel"} -->
Description
The
ForkDeathTestnative tests inddtrace/internal/datadog/profiling/dd_wrapper/test/test_forking.cppfail now and then onmainin theprofiling_nativeThreadSanitizer (thread) jobs. All five tests are affected, not onlySampleInThreadsAndForkManyFast, and only under TSan. Over the last 30 days they failed 12 times out of about 4,800 TSan runs. The death-test process exits with status 66, TSan's exit code after it prints a report, so JUnit only records "Failed".Every failure is the same report, in the parent process:
The test forks while an upload is in flight.
ProfilerState::prefork()cancels that upload from the forking thread. The cancellation wakes the exporter's single-threaded tokio runtime by writing to its eventfd. The upload thread then returns and drops the exporter, which closes the eventfd.This is not a real race. The waker holds a reference to the runtime handle, and the eventfd is only closed when the last reference is dropped, so the close always comes after the write. That ordering uses atomics in libdatadog's Rust code, which is not built with TSan, so TSan cannot see it. TSan only sees an ordering when the upload thread wakes up from
epoll_waitafter the write, because it treats that as synchronization through the epoll file descriptor. When the upload thread notices the cancellation another way, which happens more often on a busy runner, TSan reports a race on the file descriptor.The existing entries in
TSan.suppcover the same kind of false positive ("libdd is not compiled with sanitizers"). This PR adds one narrow entry,race:tokio::runtime::driver::Handle, for reports where tokio's runtime driver handle is dropped. There are no production code changes.Testing
Reproduced in the
profiling_nativeCI image (Python 3.10,build_standalone.sh --thread RelWithDebInfo stack_test). I rantest_forking --gtest_filter=ForkDeathTest.*in 10 parallel loops on 5 CPUs to mimic a busy runner:print_suppressions=1. The new entry matched in 8 runs, which confirms it is what absorbs the report, and no unsuppressed report was printed.ctestin the dd_wrapper TSan build passes: 26 tests, OOM test skipped as usual.scripts/lint checkspasses.Risks
Low, test-only. TSan will hide any race report with a tokio runtime driver handle drop in its stack. A real race in that drop would be hidden too, but TSan cannot check libdatadog's Rust code anyway.
Additional Notes
die_after_fork=0. The CI failures above are not this hang: they finish in about 1.3 s, the same as passing runs, and exit with status 66.sample_in_threads_and_forkstill never starts its parent sampler threads (idsis empty), as #16153 noted. That is unchanged here.---
PR by Bits - View session in Datadog • Open in Slack
Comment @datadog to request changes