Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8254668: JVMTI process frames on thread without started processing
Reviewed-by: eosterlund, rrich
  • Loading branch information
stefank committed Oct 14, 2020
1 parent dc262df commit db9dcdf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/hotspot/share/prims/jvmtiEnv.cpp
Expand Up @@ -1674,7 +1674,7 @@ JvmtiEnv::PopFrame(JavaThread* java_thread) {
bool is_interpreted[2];
intptr_t *frame_sp[2];
// The 2-nd arg of constructor is needed to stop iterating at java entry frame.
for (vframeStream vfs(java_thread, true); !vfs.at_end(); vfs.next()) {
for (vframeStream vfs(java_thread, true, false /* process_frames */); !vfs.at_end(); vfs.next()) {
methodHandle mh(current_thread, vfs.method());
if (mh->is_native()) return(JVMTI_ERROR_OPAQUE_FRAME);
is_interpreted[frame_count] = vfs.is_interpreted_frame();
Expand All @@ -1686,7 +1686,7 @@ JvmtiEnv::PopFrame(JavaThread* java_thread) {
// There can be two situations here:
// 1. There are no more java frames
// 2. Two top java frames are separated by non-java native frames
if(vframeFor(java_thread, 1) == NULL) {
if(vframeForNoProcess(java_thread, 1) == NULL) {
return JVMTI_ERROR_NO_MORE_FRAMES;
} else {
// Intervening non-java native or VM frames separate java frames.
Expand Down Expand Up @@ -1785,7 +1785,7 @@ JvmtiEnv::NotifyFramePop(JavaThread* java_thread, jint depth) {
JvmtiSuspendControl::print();
}

vframe *vf = vframeFor(java_thread, depth);
vframe *vf = vframeForNoProcess(java_thread, depth);
if (vf == NULL) {
return JVMTI_ERROR_NO_MORE_FRAMES;
}
Expand Down
9 changes: 5 additions & 4 deletions src/hotspot/share/prims/jvmtiEnvBase.cpp
Expand Up @@ -556,12 +556,13 @@ JvmtiEnvBase::new_jthreadGroupArray(int length, Handle *handles) {
}

// return the vframe on the specified thread and depth, NULL if no such frame
// The thread and the oops in the returned vframe might not have been process.
vframe*
JvmtiEnvBase::vframeFor(JavaThread* java_thread, jint depth) {
JvmtiEnvBase::vframeForNoProcess(JavaThread* java_thread, jint depth) {
if (!java_thread->has_last_Java_frame()) {
return NULL;
}
RegisterMap reg_map(java_thread);
RegisterMap reg_map(java_thread, true /* update_map */, false /* process_frames */);
vframe *vf = java_thread->last_java_vframe(&reg_map);
int d = 0;
while ((vf != NULL) && (d < depth)) {
Expand Down Expand Up @@ -909,7 +910,7 @@ JvmtiEnvBase::get_frame_location(JavaThread *java_thread, jint depth,
"call by myself or at handshake");
ResourceMark rm(current_thread);

vframe *vf = vframeFor(java_thread, depth);
vframe *vf = vframeForNoProcess(java_thread, depth);
if (vf == NULL) {
return JVMTI_ERROR_NO_MORE_FRAMES;
}
Expand Down Expand Up @@ -1309,7 +1310,7 @@ JvmtiEnvBase::check_top_frame(Thread* current_thread, JavaThread* java_thread,
jvalue value, TosState tos, Handle* ret_ob_h) {
ResourceMark rm(current_thread);

vframe *vf = vframeFor(java_thread, 0);
vframe *vf = vframeForNoProcess(java_thread, 0);
NULL_CHECK(vf, JVMTI_ERROR_NO_MORE_FRAMES);

javaVFrame *jvf = (javaVFrame*) vf;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/prims/jvmtiEnvBase.hpp
Expand Up @@ -286,7 +286,7 @@ class JvmtiEnvBase : public CHeapObj<mtInternal> {
javaVFrame *jvf,
GrowableArray<jvmtiMonitorStackDepthInfo*>* owned_monitors_list,
jint depth);
vframe* vframeFor(JavaThread* java_thread, jint depth);
vframe* vframeForNoProcess(JavaThread* java_thread, jint depth);

public:
// get a field descriptor for the specified class and field
Expand Down

1 comment on commit db9dcdf

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on db9dcdf Oct 14, 2020

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.