From 9f8369c5cc03d5a0121ed644c0fbb64a2360f7ed Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 15 Apr 2013 12:37:23 -0600 Subject: [PATCH] enter exclusive state in destroyJavaVM This is necessary to ensure that new threads do not start while we're shutting down (except for the ones that we start to run the shutdown hooks), and that the shutdown hook threads can be safely started (it is not safe to start threads from e.g. an idle state, and an assertion will fail if we do). --- src/jnienv.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 741da645dd..334d36d3ba 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -79,6 +79,8 @@ destroyJavaVM(Thread* t, uintptr_t*) while (t->m->liveCount - t->m->daemonCount > 1) { t->m->stateLock->wait(t->systemThread, 0); } + + enter(t, Thread::ExclusiveState); } shutDown(t);