8186437: Lock held when compiler thread creation fails

Reviewed-by: stuefe, kvn
This commit is contained in:
Goetz Lindenmaier 2017-08-22 15:12:26 +02:00
parent d1bbcb5a39
commit 192f57c11c

View File

@ -720,12 +720,10 @@ JavaThread* CompileBroker::make_thread(const char* name, CompileQueue* queue, Co
// At this point it may be possible that no osthread was created for the // 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 // 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 // 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) { if (thread != NULL && thread->osthread() != NULL) {
vm_exit_during_initialization("java.lang.OutOfMemoryError",
os::native_thread_creation_failed_msg());
}
java_lang_Thread::set_thread(thread_oop(), thread); java_lang_Thread::set_thread(thread_oop(), thread);
@ -759,6 +757,13 @@ JavaThread* CompileBroker::make_thread(const char* name, CompileQueue* queue, Co
Threads::add(thread); Threads::add(thread);
Thread::start(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 // Let go of Threads_lock before yielding
os::naked_yield(); // make sure that the compiler thread is started early (especially helpful on SOLARIS) os::naked_yield(); // make sure that the compiler thread is started early (especially helpful on SOLARIS)