GeezerVison is showing github.com — test(jfr): regression test for dump+restart race (SIGSEGV in _Rb_tree_increment) by jbachorik · Pull Request #523 · DataDog/java-profiler
Conversation
jbachorik
commented
May 11, 2026
•
edited by atlassian
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
What does this PR do?:
Adds a regression test: ConcurrentDumpRestartTest exercises the race between Recording::writeClasses (called during dump()) and Profiler::start(reset=true) which clears _class_map concurrently. Without the fix in the base branch (muse/sigsegv-in-profiler-dump), this race corrupts rbtree node pointers and causes a SIGSEGV in std::_Rb_tree_increment. A crash aborts the JVM, which JUnit reports as a test failure.
Motivation:
Three production crash events (2026-05-06 to 2026-05-08, fingerprint v10.DAECC680F0728EAB44F26DB0B91B703F) on Amazon Corretto 21 showed SIGSEGV in std::_Rb_tree_increment reached via Recording::writeCpool → Recording::writeClasses → Dictionary::collect. The fix (holding classMapSharedGuard() for the full duration of writeClasses) is in the base PR #516. This PR adds the regression test so the fix is verified and the race cannot regress silently.
Additional Notes:
Stacked on PR #516 (muse/sigsegv-in-profiler-dump). Merge this after PR #516 lands.
How to test the change?:
- Run under ASAN build:
./gradlew :ddprof-test:testRelease --tests "*.ConcurrentDumpRestartTest". Without the fix the test crashes the JVM; with the fix it completes cleanly.
For Datadog employees:
- If this PR touches code that signs or publishes builds or packages, or handles
credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
- This PR doesn't touch any of that.
- JIRA: PROF-14583
Unsure? Have a question? Request a review!
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
walkVM ran the inserting Dictionary::lookup from a signal handler, calling
malloc/calloc — async-signal-unsafe. Recording::writeClasses also walked
_class_map without holding _class_map_lock, racing the exclusive clear()
that follows in Profiler::dump.
Switch the vtable-target site to bounded_lookup(..., 0) and skip the
synthetic frame on miss; hold _class_map_lock shared while writeClasses
recurses into Dictionary::collect; document the signal-safety hazard on
the inserting overloads; add a concurrent test for the lock discipline.
Fixes PROF-14549.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codex flagged a remaining race after the initial fix: walkVM's read-only
bounded_lookup still traverses row->next and reads row->keys[j] without
holding _class_map_lock, while Profiler::dump's exclusive _class_map.clear()
runs in the unlockAll -> lock window and free()s those same nodes/strings.
Take _class_map_lock shared via OptionalSharedLockGuard (try-lock so the
signal handler never blocks). When an exclusive clear() is in progress,
drop the synthetic vtable-target frame instead of dereferencing freed
memory.
Also add the missing <cstring> include in dictionary_concurrent_ut.cpp;
strlen() previously worked only via a transitive include through
gtest_crash_handler.h.
Addresses review comments on PR #512.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
flightRecorder.cpp: refer to classMap()/classMapLock() rather
than the underlying _class_map/_class_map_lock fields.
dictionary_concurrent_ut.cpp: drop PROF-14549 ticket reference.
Co-Authored-By: muse <muse@noreply>
… vs dump clear
Adds SignalHandlerBoundedLookupVsDumpClear: concurrent signal-handler threads
(OptionalSharedLockGuard + bounded_lookup(0)) vs a dump thread (exclusive lock
+ dict.clear()), reproducing the PROF-14550 crash signature without the fix.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…fter-unlock in writeClasses; cap tryLockShared at 5 attempts
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…unded variant
- ddprof-lib/src/main/cpp/spinLock.h:49 — restored tryLockShared() to spin until exclusive lock released; added tryLockSharedBounded() for signal-handler paths
- ddprof-lib/src/main/cpp/spinLock.h:102 — OptionalSharedLockGuard updated to use tryLockSharedBounded()
Co-Authored-By: muse <muse@noreply>
- ddprof-lib/src/main/cpp/spinLock.h:115 — OptionalSharedLockGuard reverted to tryLockShared() (non-spurious) for FlightRecorder hot paths; BoundedOptionalSharedLockGuard added for signal-handler-only callers
- ddprof-lib/src/main/cpp/profiler.h:208 — classMapTrySharedGuard() now returns BoundedOptionalSharedLockGuard
Co-Authored-By: muse <muse@noreply>
…ounded unit tests
- spinlock_bounded_ut.cpp: 6 tests covering tryLockSharedBounded() and
BoundedOptionalSharedLockGuard in isolation (free lock, exclusive-held
failure, multiple shared holders, RAII destruction, concurrent stress)
- dictionary_concurrent_ut.cpp: update SignalHandlerBoundedLookupVsDumpClear
to use BoundedOptionalSharedLockGuard matching the actual hotspotSupport.cpp
code path (classMapTrySharedGuard())
Co-Authored-By: muse <muse@noreply>
…nalSharedLockGuard
Restore OptionalSharedLockGuard in SignalHandlerBoundedLookupVsDumpClear and
add SignalHandlerBoundedOptionalLookupVsDumpClear for BoundedOptionalSharedLockGuard,
which is what classMapTrySharedGuard() returns in hotspotSupport.cpp.
Co-Authored-By: muse <muse@noreply>
Exercises the race where Profiler::start(reset=true) clears _class_map
concurrently with Recording::writeClasses iterating its row keys, which
corrupted rbtree nodes and caused SIGSEGV in std::_Rb_tree_increment.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
dd-octo-sts
Bot
commented
May 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
CI Test Results
Run: #25728877379 | Commit: 4eacf6c | Duration: 3h 0m 19s (longest job)
❌ 1 of 54 test jobs failed
Status Overview
| JDK |
glibc-aarch64/asan |
glibc-aarch64/debug |
glibc-amd64/asan |
glibc-amd64/debug |
musl-aarch64/debug |
musl-amd64/debug |
| 8 |
- |
- |
✅ |
✅ |
- |
- |
| 8-ibm |
- |
- |
✅ |
✅ |
- |
- |
| 8-j9 |
✅ |
✅ |
✅ |
✅ |
- |
- |
| 8-librca |
- |
- |
- |
- |
✅ |
✅ |
| 8-orcl |
- |
- |
✅ |
✅ |
- |
- |
| 11 |
- |
- |
✅ |
✅ |
- |
- |
| 11-j9 |
✅ |
✅ |
✅ |
✅ |
- |
- |
| 11-librca |
- |
- |
- |
- |
✅ |
✅ |
| 17 |
✅ |
✅ |
✅ |
✅ |
- |
- |
| 17-graal |
✅ |
✅ |
✅ |
✅ |
- |
- |
| 17-j9 |
✅ |
✅ |
✅ |
✅ |
- |
- |
| 17-librca |
- |
- |
- |
- |
✅ |
✅ |
| 21 |
✅ |
✅ |
✅ |
✅ |
- |
- |
| 21-graal |
❌ |
✅ |
✅ |
✅ |
- |
- |
| 21-librca |
- |
- |
- |
- |
✅ |
✅ |
| 25 |
✅ |
✅ |
✅ |
✅ |
- |
- |
| 25-graal |
🚫 |
✅ |
✅ |
✅ |
- |
- |
| 25-librca |
- |
- |
- |
- |
✅ |
✅ |
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled
Failed Tests
glibc-aarch64/asan / 21-graal
Job: View logs
No detailed failure information available. Check the job logs.
Summary: Total: 54 | Passed: 52 | Failed: 1 | Cancelled: 1
Updated: 2026-05-12 13:42:13 UTC
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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: c814ce0ddf
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds a JUnit regression/stress test in ddprof-test to exercise the previously observed race between dump() (JFR constant-pool/class writing) and start(reset=true) (_class_map clearing), which historically could corrupt RB-tree iterators and crash the JVM (PROF-14583). This is intended to ensure the fix from stacked PR #516 doesn’t regress.
Changes:
- Introduce
ConcurrentDumpRestartTest that runs allocator worker threads while repeatedly dumping JFR recordings and concurrently stop/starting the profiler.
- Add basic progress assertions (minimum number of dumps/restarts) to avoid trivially-successful runs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jbachorik
changed the title
test(jfr): regression test for PROF-14583 dump+restart race (SIGSEGV in _Rb_tree_increment)
test(jfr): regression test for dump+restart race (SIGSEGV in _Rb_tree_increment)
May 11, 2026
- Add Datadog Apache 2.0 copyright header
- Add volatile allocSink to prevent JIT from eliminating test allocations
- Build restart command from getProfilerCommand() + injected cstack
- Capture restarter thread exceptions; InterruptedException is expected
- Count only non-empty dumps (profiler.dump() is no-op when IDLE)
Co-Authored-By: muse <muse@noreply>
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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: 46ebfb9b51
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Copilot
AI
commented
May 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
@codex review
Reviewed the latest changes at 46ebfb9; no additional issues found and no further code changes are needed.
@codex review
Completed another pass on 46ebfb9; the previously requested fixes are present and I did not find new issues requiring changes.
@copilot review
I re-reviewed the branch at 46ebfb9. Current test logic looks consistent with prior feedback and no extra patch is required.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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: 46ebfb9b51
ℹ️ 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".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
alloc=1ms is not recognized by Arguments::parse — only event=alloc and
memory=<interval>[:<config>] are valid. Switch to memory=262144:a so
allocating threads actually populate _class_map via ObjectSampler.
- ddprof-test/src/test/java/com/datadoghq/profiler/jfr/ConcurrentDumpRestartTest.java:68 — memory=262144:a,wall=5ms
Co-Authored-By: muse <muse@noreply>
… handler and dump path (#516)
Base automatically changed from
muse/sigsegv-in-profiler-dump
to
muse/sigsegv-in-recording-writeclasses
May 12, 2026 10:20
…-sigsegv-in-std-rb-tree-increment-clean
Base automatically changed from
muse/sigsegv-in-recording-writeclasses
to
main
May 12, 2026 11:02
|
Closing: ConcurrentDumpRestartTest moved to PR #522. The C++ test additions (dictionary_concurrent_ut.cpp, spinlock_bounded_ut.cpp) were already merged into main via PR #512.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
AI
test:asan
Run CI tests with AddressSanitizer configuration
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|