comparison src/share/vm/prims/jvmtiEnvThreadState.cpp @ 13415:c8c2d6b82499

8028126: nsk/jvmti/scenarios/hotswap/HS101/hs101t006 Crashed the vm on Solaris-sparc64 fastdebug builds: only current thread can flush its registers Summary: Fix a race between VMOp_GetCurrentLocation reaching a safepoint and arget thread exiting from Java execution Reviewed-by: sla, dholmes, dsamersoff Contributed-by: serguei.spitsyn@oracle.com
author sspitsyn
date Tue, 03 Dec 2013 15:41:35 -0800
parents da91efe96a93
children de6a9e811145
comparison
equal deleted inserted replaced
13413:7a58803b5069 13415:c8c2d6b82499
267 } 267 }
268 VMOp_Type type() const { return VMOp_GetCurrentLocation; } 268 VMOp_Type type() const { return VMOp_GetCurrentLocation; }
269 void doit() { 269 void doit() {
270 ResourceMark rmark; // _thread != Thread::current() 270 ResourceMark rmark; // _thread != Thread::current()
271 RegisterMap rm(_thread, false); 271 RegisterMap rm(_thread, false);
272 javaVFrame* vf = _thread->last_java_vframe(&rm); 272 // There can be a race condition between a VM_Operation reaching a safepoint
273 assert(vf != NULL, "must have last java frame"); 273 // and the target thread exiting from Java execution.
274 Method* method = vf->method(); 274 // We must recheck the last Java frame still exists.
275 _method_id = method->jmethod_id(); 275 if (_thread->has_last_Java_frame()) {
276 _bci = vf->bci(); 276 javaVFrame* vf = _thread->last_java_vframe(&rm);
277 assert(vf != NULL, "must have last java frame");
278 Method* method = vf->method();
279 _method_id = method->jmethod_id();
280 _bci = vf->bci();
281 } else {
282 // Clear current location as the target thread has no Java frames anymore.
283 _method_id = (jmethodID)NULL;
284 _bci = 0;
285 }
277 } 286 }
278 void get_current_location(jmethodID *method_id, int *bci) { 287 void get_current_location(jmethodID *method_id, int *bci) {
279 *method_id = _method_id; 288 *method_id = _method_id;
280 *bci = _bci; 289 *bci = _bci;
281 } 290 }