Skip to content

Commit

Permalink
8302320: AsyncGetCallTrace obtains too few frames in sanity test
Browse files Browse the repository at this point in the history
Backport-of: db483a38a815f85bd9668749674b5f0f6e4b27b4
  • Loading branch information
parttimenerd authored and TheRealMDoerr committed Mar 15, 2023
1 parent bc79161 commit 4baaa11
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/hotspot/cpu/x86/frame_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ bool frame::safe_for_sender(JavaThread *thread) {
return false;
}

// unextended sp must be within the stack and above or equal sp
if (!thread->is_in_stack_range_incl(unextended_sp, sp)) {
// unextended sp must be within the stack
// Note: sp can be greater than unextended_sp in the case of
// interpreted -> interpreted calls that go through a method handle linker,
// since those pop the last argument (the appendix) from the stack.
if (!thread->is_in_stack_range_incl(unextended_sp, sp - Interpreter::stackElementSize)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,40 @@ Java_MyPackage_ASGCTBaseTest_checkAsyncGetCallTraceCall(JNIEnv* env, jclass cls)
return false;
}

return strcmp(name.get(), "checkAsyncGetCallTraceCall") == 0;
if (strcmp(name.get(), "checkAsyncGetCallTraceCall") != 0) {
fprintf(stderr, "Name is not checkAsyncGetCallTraceCall: %s\n", name.get());
return false;
}

// AsyncGetCallTrace and GetStackTrace should return comparable frames
// so we obtain the frames using GetStackTrace and compare them.

jthread thread;
jvmti->GetCurrentThread(&thread);
jvmtiFrameInfo gstFrames[MAX_DEPTH];
jint gstCount = 0;

jvmti->GetStackTrace(thread, 0, MAX_DEPTH, gstFrames, &gstCount);

if (gstCount != trace.num_frames) {
fprintf(stderr, "GetStackTrace and AsyncGetCallTrace return different number of frames: %d vs %d)", gstCount, trace.num_frames);
return false;
}

for (int i = 0; i < trace.num_frames; ++i) {
if (trace.frames[i].lineno == -3) {
if (gstFrames[i].location != -1) {
fprintf(stderr, "%d: ASGCT found native frame but GST did not\n", i);
return false;
}
} else {
if (gstFrames[i].method != trace.frames[i].method_id) {
fprintf(stderr, "%d: method_id mismatch: %p vs %p\n", i, gstFrames[i].method, trace.frames[i].method_id);
return false;
}
}
}
return true;
}

}

1 comment on commit 4baaa11

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.