# HG changeset patch # User sspitsyn # Date 1386107770 28800 # Node ID e84d2afb2fb099862b71c290b755a40bb6d49d9e # Parent c8c2d6b824997d0cc40aa95887ab3f85e565e158# Parent 379f11bc04fc42563d54dfa8f23507e268563cc8 Merge diff -r 379f11bc04fc -r e84d2afb2fb0 src/share/vm/prims/jvmtiEnvThreadState.cpp --- a/src/share/vm/prims/jvmtiEnvThreadState.cpp Tue Dec 03 11:13:14 2013 -0800 +++ b/src/share/vm/prims/jvmtiEnvThreadState.cpp Tue Dec 03 13:56:10 2013 -0800 @@ -269,11 +269,20 @@ void doit() { ResourceMark rmark; // _thread != Thread::current() RegisterMap rm(_thread, false); - javaVFrame* vf = _thread->last_java_vframe(&rm); - assert(vf != NULL, "must have last java frame"); - Method* method = vf->method(); - _method_id = method->jmethod_id(); - _bci = vf->bci(); + // There can be a race condition between a VM_Operation reaching a safepoint + // and the target thread exiting from Java execution. + // We must recheck the last Java frame still exists. + if (_thread->has_last_Java_frame()) { + javaVFrame* vf = _thread->last_java_vframe(&rm); + assert(vf != NULL, "must have last java frame"); + Method* method = vf->method(); + _method_id = method->jmethod_id(); + _bci = vf->bci(); + } else { + // Clear current location as the target thread has no Java frames anymore. + _method_id = (jmethodID)NULL; + _bci = 0; + } } void get_current_location(jmethodID *method_id, int *bci) { *method_id = _method_id;