Mercurial > hg > truffle
diff src/share/vm/prims/jvmtiEnv.cpp @ 14653:0d8d78c0329a
6471769: Error: assert(_cur_stack_depth == count_frames(),"cur_stack_depth out of sync")
Summary: It is more safe to get/update data for suspended threads at a safepoint
Reviewed-by: dcubed, twisti, dholmes
Contributed-by: serguei.spitsyn@oracle.com
author | sspitsyn |
---|---|
date | Sat, 01 Mar 2014 08:05:55 -0800 |
parents | 402677ca28ed |
children | b51e29501f30 |
line wrap: on
line diff
--- a/src/share/vm/prims/jvmtiEnv.cpp Sat Mar 01 01:36:48 2014 -0800 +++ b/src/share/vm/prims/jvmtiEnv.cpp Sat Mar 01 08:05:55 2014 -0800 @@ -1464,7 +1464,19 @@ // It's fine to update the thread state here because no JVMTI events // shall be posted for this PopFrame. - state->update_for_pop_top_frame(); + // It is only safe to perform the direct operation on the current + // thread. All other usage needs to use a vm-safepoint-op for safety. + if (java_thread == JavaThread::current()) { + state->update_for_pop_top_frame(); + } else { + VM_UpdateForPopTopFrame op(state); + VMThread::execute(&op); + jvmtiError err = op.result(); + if (err != JVMTI_ERROR_NONE) { + return err; + } + } + java_thread->set_popframe_condition(JavaThread::popframe_pending_bit); // Set pending step flag for this popframe and it is cleared when next // step event is posted. @@ -1505,6 +1517,7 @@ // depth - pre-checked as non-negative jvmtiError JvmtiEnv::NotifyFramePop(JavaThread* java_thread, jint depth) { + jvmtiError err = JVMTI_ERROR_NONE; ResourceMark rm; uint32_t debug_bits = 0; @@ -1532,10 +1545,17 @@ assert(vf->frame_pointer() != NULL, "frame pointer mustn't be NULL"); - int frame_number = state->count_frames() - depth; - state->env_thread_state(this)->set_frame_pop(frame_number); - - return JVMTI_ERROR_NONE; + // It is only safe to perform the direct operation on the current + // thread. All other usage needs to use a vm-safepoint-op for safety. + if (java_thread == JavaThread::current()) { + int frame_number = state->count_frames() - depth; + state->env_thread_state(this)->set_frame_pop(frame_number); + } else { + VM_SetFramePop op(this, state, depth); + VMThread::execute(&op); + err = op.result(); + } + return err; } /* end NotifyFramePop */