Serialize stale jmethodID frames as <unloaded> instead of jvmtiError - #744
Merged
Conversation
Contributor
Scan-Build Report
Bug Summary
Reports
|
||||||||||||||||||||||||||||||||||||
jbachorik
force-pushed
the
fix/jvmtiError
branch
from
August 19, 2026 15:31
b13e956 to
a3bacde
Compare
jbachorik
marked this pull request as ready for review
August 19, 2026 15:35
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3bacdea1d
ℹ️ 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".
Contributor
This comment has been minimized.
This comment has been minimized.
jbachorik
force-pushed
the
fix/jvmtiError
branch
2 times, most recently
from
August 19, 2026 16:36
79540b0 to
b21f7cd
Compare
zhengyu123
requested changes
Aug 19, 2026
Contributor
CI Test ResultsRun: #32352690944 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-08-20 09:29:51 UTC |
JDK-8268406 (JDK 26) freed jmethodID memory on class unload, so the profiler's deref-based stale-jmethodID detection (validatedId deref + check_jmethodID) -- disabled for JDK > 25 -- can no longer catch stale IDs at capture time. A stale jmethodID from an unloaded/purged class passes all capture gates, reaches fillJavaMethodInfo at dump time, and GetMethodDeclaringClass returns JVMTI_ERROR_INVALID_METHODID. The frame was serialized as the synthetic 'jvmtiError' method, which surfaced as all-leaf jvmtiError frames in hotdog during the early class-churn window (regression vs v1.49.0, which ran on JDK <= 25). Remap the dump-time resolution failure branch to '<unloaded>', matching the angle-bracket synthetic-frame convention (<remote>, <vtable_receiver>). This is the correct and safe label: the method was present at sample time, its metadata was reclaimed before the JFR dump. The capture-time 'unknown' path (JMETHODID_NOT_WALKABLE / null jmethodID) stays distinct. Remove the now-dead jvmtiError assertions from SmokeCpuTest, SmokeWallTest, CTimerSamplerTest and RemoteSymbolicationTest: the label is no longer emitted anywhere, so those checks can never fail.
jbachorik
force-pushed
the
fix/jvmtiError
branch
from
August 20, 2026 09:12
b21f7cd to
54a8d9d
Compare
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?:
Remaps the dump-time JVMTI-resolution failure branch in
Lookup::fillJavaMethodInfo(flightRecorder.cpp) to serialize the frame as<unloaded>instead of the syntheticjvmtiErrormethod name. Removes the now-deadjvmtiErrorassertions fromSmokeCpuTest,SmokeWallTest,CTimerSamplerTest, andRemoteSymbolicationTest.Motivation:
Profiles in hotdog (non-
remotesym) showed all leaf frames serialized asjvmtiErrorduring the early class-churn window (~first 10-15 min), a regression vs v1.49.0.Root cause is JDK-8268406 "Deallocate jmethodID native memory" (integrated in JDK 26, build b05): jmethodID memory is now freed on class unload (pre-26 it was kept alive — the leak this change fixed). The profiler's stale-jmethodID detection relies on dereferencing the jmethodID to verify it still points to the right
Method*:VMMethod::check_jmethodID_hotspot(vmStructs.cpp):if (hotspot_version() > 25) return true;— unconditional, no validation._can_dereference_jmethod_id = _has_method_structs && hotspot_version() <= 25(vmStructs.cpp):validatedId()skips the deref.Both are disabled for JDK > 25 because the deref no longer aliases a kept-alive
JNIMethodBlock— it would fault on freed memory. So a stale jmethodID from an unloaded/purged class passes all capture-time gates, reachesfillJavaMethodInfoat dump time,GetMethodDeclaringClassreturnsJVMTI_ERROR_INVALID_METHODID, and the frame was serialized asjvmtiError.Per the JVMTI spec, retransform does not invalidate jmethodIDs (the original ID is repurposed to the new method version). What invalidates them is class unload — and JDK-8268406 changed what "invalidated" means at the memory level. The early-run correlation is class churn (generated accessors, lambda forms, Mockito-generated classes, retransform obsolete-method purge via the JDK-8313816 path) which settles after warmup.
<unloaded>is the correct, safe label: the method was present at sample time, its metadata was reclaimed before the JFR dump. It matches the existing angle-bracket synthetic-frame convention (<remote>,<vtable_receiver>,<unresolved_vtable_receiver>). The capture-timeunknownpath (JMETHODID_NOT_WALKABLE/ null jmethodID) stays distinct, so the two failure modes remain distinguishable in profiles:unknown— capture-time validation failure (walker couldn't trust the ID).<unloaded>— dump-time resolution failure (ID was valid at capture, metadata reclaimed by dump).Additional Notes:
Method*(the alternative) is crash-prone on class unload and reverts Avoid retaining invalid VM method pointers #699's safety work; on JDK 26 theMethod*is freed too.jvmtiErrorlabel is no longer emitted by any code path, so the per-test assertions against it were dead checks that could never fail — removed rather than kept as sentinels.How to test the change?:
SmokeCpuTest+ 391 gtests pass (0 failures) on Corretto 26. A reproducing test that forces a class unload during profiling to lock in the<unloaded>behavior can be added as a follow-up.For Datadog employees: