Skip to content

Commit 7fb3373

Browse files
jbachorikclaude
andcommitted
Fix J9 JVM segfault in dropped trace method resolution
The dropped trace was incorrectly setting bci=0 and casting a string literal to jmethodID, causing JVMTI calls like GetMethodDeclaringClass() to segfault when processing the JFR constant pool during shutdown. Fixed by setting bci=BCI_ERROR to properly route the dropped trace to native method resolution (fillNativeMethodInfo) instead of Java method resolution (fillJavaMethodInfo), avoiding JVMTI calls on invalid method IDs. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c96dc57 commit 7fb3373

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ddprof-lib/src/main/cpp/callTraceStorage.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "callTraceStorage.h"
88
#include "counters.h"
99
#include "common.h"
10+
#include "vmEntry.h" // For BCI_ERROR constant
1011
#include <string.h>
1112
#include <atomic>
1213

@@ -46,6 +47,7 @@ CallTraceStorage::~CallTraceStorage() {
4647

4748
CallTrace* CallTraceStorage::getDroppedTrace() {
4849
// Static dropped trace object - created once and reused
50+
static const char dropped_method_name[] = "<dropped due to contention>";
4951
static struct {
5052
CallTrace trace;
5153
ASGCT_CallFrame frame; // Additional frame storage beyond the [1] in CallTrace
@@ -55,8 +57,8 @@ CallTrace* CallTraceStorage::getDroppedTrace() {
5557
.num_frames = 1,
5658
.trace_id = DROPPED_TRACE_ID,
5759
.frames = {{
58-
.bci = 0,
59-
.method_id = (jmethodID)"<dropped due to contention>"
60+
.bci = BCI_ERROR, // Mark as native frame with error string
61+
.method_id = (jmethodID)dropped_method_name // String name for native frame
6062
}}
6163
},
6264
.frame = {} // Unused but needed for proper alignment

0 commit comments

Comments
 (0)