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
Reviewed-by: jvernee, dholmes, rrich
  • Loading branch information
parttimenerd authored and JornVernee committed Feb 21, 2023
1 parent 02eb240 commit db483a3
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 @@ -68,8 +68,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;
}

}

7 comments on commit db483a3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@parttimenerd
Copy link
Contributor Author

@parttimenerd parttimenerd commented on db483a3 Mar 6, 2023

Choose a reason for hiding this comment

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

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on db483a3 Mar 6, 2023

Choose a reason for hiding this comment

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

@parttimenerd Usage: /backport <repository> [<branch>]

@parttimenerd
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on db483a3 Mar 6, 2023

Choose a reason for hiding this comment

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

@parttimenerd the backport was successfully created on the branch parttimenerd-backport-db483a38 in my personal fork of openjdk/jdk17u. To create a pull request with this backport targeting openjdk/jdk17u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit db483a38 from the openjdk/jdk repository.

The commit being backported was authored by Johannes Bechberger on 21 Feb 2023 and was reviewed by Jorn Vernee, David Holmes and Richard Reingruber.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u:

$ git fetch https://github.com/openjdk-bots/jdk17u parttimenerd-backport-db483a38:parttimenerd-backport-db483a38
$ git checkout parttimenerd-backport-db483a38
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u parttimenerd-backport-db483a38

@parttimenerd
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on db483a3 Mar 6, 2023

Choose a reason for hiding this comment

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

@parttimenerd the backport was successfully created on the branch parttimenerd-backport-db483a38 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit db483a38 from the openjdk/jdk repository.

The commit being backported was authored by Johannes Bechberger on 21 Feb 2023 and was reviewed by Jorn Vernee, David Holmes and Richard Reingruber.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev parttimenerd-backport-db483a38:parttimenerd-backport-db483a38
$ git checkout parttimenerd-backport-db483a38
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev parttimenerd-backport-db483a38

Please sign in to comment.