Skip to content

wip: #615

Draft
zhengyu123 wants to merge 5 commits into
mainfrom
zgu/objmonitor_deflation
Draft

wip: #615
zhengyu123 wants to merge 5 commits into
mainfrom
zgu/objmonitor_deflation

Conversation

@zhengyu123

Copy link
Copy Markdown
Contributor

What does this PR do?:

Motivation:

Additional Notes:

How to test the change?:

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 security review (run the dd:platform-security-review
    skill, or file a request via the PSEC review form).
    bewaire also runs automatically on every PR.
  • This PR doesn't touch any of that.
  • JIRA: [JIRA-XXXX]

Unsure? Have a question? Request a review!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 via VMThread::isJavaThread().
  • Harden VMKlass::fromOop() against concurrent monitor deflation by using SafeAccess::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.

Comment thread ddprof-lib/src/test/cpp/hotspot_crash_protection_ut.cpp
Comment on lines +170 to +174
// 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
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 24, 2026

Copy link
Copy Markdown

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 20 Pipeline jobs failed

CI Run | test-matrix / test-linux-musl-aarch64 (11-librca, debug)   View in Datadog   GitHub Actions

CI Run | test-matrix / test-linux-musl-aarch64 (25-librca, debug)   View in Datadog   GitHub Actions

DataDog/java-profiler | post-pr-comment   View in Datadog   GitLab

View all 20 failed jobs.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c6936b5 | Docs | Datadog PR Page | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

CI Test Results

Run: #28139121031 | Commit: e3ca74a | Duration: 12m 47s (longest job)

5 of 32 test jobs failed

Status Overview

JDK glibc-aarch64/debug 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

musl-aarch64/debug / 11-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-aarch64/debug / 8-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-aarch64/debug / 21-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-aarch64/debug / 25-librca

Job: View logs

No detailed failure information available. Check the job logs.

musl-aarch64/debug / 17-librca

Job: 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

zhengyu123 and others added 4 commits June 24, 2026 16:58
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>
@dd-octo-sts

dd-octo-sts Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Reliability & Chaos Results

All reliability & chaos checks passed Pipeline: https://gitlab.ddbuild.io/DataDog/java-profiler/-/pipelines/120907300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants