< prev index next >

src/share/vm/compiler/compileBroker.cpp

Print this page
rev 13469 : 8186437: Lock held when compiler thread creation fails.
Reviewed-by: stuefe

@@ -718,16 +718,14 @@
 
 
     // At this point it may be possible that no osthread was created for the
     // JavaThread due to lack of memory. We would have to throw an exception
     // in that case. However, since this must work and we do not allow
-    // exceptions anyway, check and abort if this fails.
+    // exceptions anyway, check and abort if this fails. But first release the
+    // lock.
 
-    if (thread == NULL || thread->osthread() == NULL) {
-      vm_exit_during_initialization("java.lang.OutOfMemoryError",
-                                    os::native_thread_creation_failed_msg());
-    }
+    if (thread != NULL && thread->osthread() != NULL) {
 
     java_lang_Thread::set_thread(thread_oop(), thread);
 
     // Note that this only sets the JavaThread _priority field, which by
     // definition is limited to Java priorities and not OS priorities.

@@ -757,10 +755,17 @@
       thread->as_CompilerThread()->set_compiler(comp);
     }
     Threads::add(thread);
     Thread::start(thread);
   }
+  }
+
+  // First release lock before aborting VM.
+  if (thread == NULL || thread->osthread() == NULL) {
+    vm_exit_during_initialization("java.lang.OutOfMemoryError",
+                                  os::native_thread_creation_failed_msg());
+  }
 
   // Let go of Threads_lock before yielding
   os::naked_yield(); // make sure that the compiler thread is started early (especially helpful on SOLARIS)
 
   return thread;
< prev index next >