diff src/share/vm/prims/jvmtiExport.cpp @ 2126:db2b0f8c1cef

6814943: getcpool001 catches more than one JvmtiThreadState problem Summary: Mark field volatile, use membars, and change access order to close race Reviewed-by: dcubed, dholmes
author kamg
date Tue, 11 Jan 2011 10:06:00 -0500
parents 7246a374a9f2
children 9afee0b9fc1d
line wrap: on
line diff
--- a/src/share/vm/prims/jvmtiExport.cpp	Mon Jan 10 17:14:53 2011 -0500
+++ b/src/share/vm/prims/jvmtiExport.cpp	Tue Jan 11 10:06:00 2011 -0500
@@ -2253,12 +2253,14 @@
 
 void JvmtiExport::cleanup_thread(JavaThread* thread) {
   assert(JavaThread::current() == thread, "thread is not current");
-
+  MutexLocker mu(JvmtiThreadState_lock);
 
-  // This has to happen after the thread state is removed, which is
-  // why it is not in post_thread_end_event like its complement
-  // Maybe both these functions should be rolled into the posts?
-  JvmtiEventController::thread_ended(thread);
+  if (thread->jvmti_thread_state() != NULL) {
+    // This has to happen after the thread state is removed, which is
+    // why it is not in post_thread_end_event like its complement
+    // Maybe both these functions should be rolled into the posts?
+    JvmtiEventController::thread_ended(thread);
+  }
 }
 
 void JvmtiExport::oops_do(OopClosure* f) {