Add deadlock event with JVMTI-captured stacktraces#470
Draft
Add deadlock event with JVMTI-captured stacktraces#470
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jbachorik
commented
Apr 14, 2026
jbachorik
commented
Apr 14, 2026
jbachorik
commented
Apr 14, 2026
- Simplify lock_name truncation with inline min() - Add JVMTI safepoint warning on captureStackTrace - Move DeadlockDetector to test-only; profiler exposes only recordDeadlock API - Remove startDeadlockDetector/stopDeadlockDetector from JavaProfiler - Use before()/after() hooks in test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CI Test ResultsRun: #24452346678 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-04-15 12:05:20 UTC |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?:
Adds a native JFR deadlock event (
datadog.DeadlockedThread) that captures realJVMTI stacktraces for both the deadlocked thread and the lock owner. This provides
proper navigable stacktraces in JFR tools — a significant improvement over the
string-based stacks in the dd-trace-java fallback implementation.
Key components:
T_DEADLOCKJFR event type with fields: deadlockId, eventThread, stackTrace,lockName, lockOwnerThread, lockOwnerStackTrace
GetStackTrace()capture for both threads in the deadlock pair, stored inthe profiler's
CallTraceStorageas real stacktrace constant pool referencesDeadlockDetectorJava class usingThreadMXBean.findDeadlockedThreads()withperiodic polling on a daemon thread
JavaProfiler.startDeadlockDetector()/stopDeadlockDetector()lifecycle APIMotivation:
PROF-11534 — The existing deadlock event in dd-trace-java uses JDK JFR with string
stacktraces. This PR adds the improved native implementation in java-profiler that
captures real stacktraces via JVMTI, which dd-trace-java can use when the profiler
is loaded.
Additional Notes:
DeadlockEventFactoryas a fallback forenvironments where the profiler isn't loaded
deadlockIdjava.util.concurrentlock deadlocks (falls back tofindMonitorDeadlockedThreads()when synchronizer usage is not supported)How to test the change?:
./gradlew ddprof-test:testRelease --tests '*DeadlockDetectionTest*'The test creates a real deadlock between two threads, starts the detector with a
100ms interval, and verifies that
datadog.DeadlockedThreadevents appear in theprofiler's JFR output with non-empty stacktraces and matching deadlock IDs.
For Datadog employees:
credentials of any kind, I've requested a review from
@DataDog/security-design-and-guidance.🤖 Generated with Claude Code via muse implement