wip: #615
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a HotSpot JDK 25.0.2+ crash involving MonitorDeflationThread by tightening crash-protection setup in the VM stack walker and hardening a TOCTOU-prone monitor dereference. It also adds regression tests in both ddprof-test (Java) and ddprof-lib (gtest) to cover the new behavior.
Changes:
- Gate
walkVM()crash-protection setup (ThreadShadow::_exception_file/VMThread::exception()) to only apply to “real” Java application threads viaVMThread::isJavaThread(). - Harden
VMKlass::fromOop()against concurrent monitor deflation by usingSafeAccess::safeFetch64()for the monitor pointer dereference. - Add Java + C++ regression/unit tests targeting the MonitorDeflationThread crash scenario and the new gating logic.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| ddprof-test/src/test/java/com/datadoghq/profiler/cpu/MonitorDeflationThreadSafetyTest.java | Adds a regression test intended to reproduce Monitor inflation/deflation while CPU profiling signals are active. |
| ddprof-lib/src/test/cpp/hotspot_crash_protection_ut.cpp | Adds gtest coverage for ProfiledThread classification and vtable-vote behavior used by VMThread::isJavaThread(). |
| ddprof-lib/src/main/cpp/hotspot/vmStructs.h | Uses safeFetch64 to avoid a crash when dereferencing an ObjectMonitor* that may be concurrently freed by deflation. |
| ddprof-lib/src/main/cpp/hotspot/hotspotSupport.cpp | Gates crash-protection activation to avoid writing _exception_file for JVM-internal threads; adds null-guard for vtable receiver klass lookup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Only write _exception_file for real Java application threads. | ||
| // JVM-internal threads like MonitorDeflationThread are JavaThread subclasses | ||
| // in JDK 25+ (different vtable → isJavaThread() returns false) but they are | ||
| // not regular application threads. Writing _exception_file for them disturbs | ||
| // JDK 25's ObjectMonitorDeflationSafepointer, which reads thread state at |
|
CI Test ResultsRun: #28139121031 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Failed Testsmusl-aarch64/debug / 11-librcaJob: View logs No detailed failure information available. Check the job logs. musl-aarch64/debug / 8-librcaJob: View logs No detailed failure information available. Check the job logs. musl-aarch64/debug / 21-librcaJob: View logs No detailed failure information available. Check the job logs. musl-aarch64/debug / 25-librcaJob: View logs No detailed failure information available. Check the job logs. musl-aarch64/debug / 17-librcaJob: View logs No detailed failure information available. Check the job logs. Summary: Total: 32 | Passed: 27 | Failed: 5 Updated: 2026-06-25 00:59:22 UTC |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Reliability & Chaos Results✅ All reliability & chaos checks passed Pipeline: https://gitlab.ddbuild.io/DataDog/java-profiler/-/pipelines/120907300 |
What does this PR do?:
Motivation:
Additional Notes:
How to test the change?:
For Datadog employees:
credentials of any kind, I've requested a security review (run the
dd:platform-security-reviewskill, or file a request via the PSEC review form).
bewairealso runs automatically on every PR.Unsure? Have a question? Request a review!