From fc84f62a65e638ea2231492028fd60704957b8a9 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Fri, 22 Feb 2013 16:33:07 -0700 Subject: [PATCH] prevent garbage collection as vm shuts down --- src/machine.cpp | 5 +++-- src/machine.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index c070391f2a..b65d57360e 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2885,7 +2885,8 @@ doCollect(Thread* t, Heap::CollectionType type) } if ((root(t, Machine::ObjectsToFinalize) or root(t, Machine::ObjectsToClean)) - and m->finalizeThread == 0) + and m->finalizeThread == 0 + and t->state != Thread::ExitState) { m->finalizeThread = m->processor->makeThread (m, root(t, Machine::FinalizerThread), m->rootThread); @@ -3452,7 +3453,7 @@ enter(Thread* t, Thread::State s) switch (t->state) { case Thread::ExclusiveState: { assert(t, t->m->exclusive == t); - t->m->exclusive = 0; + // exit state should also be exclusive, so don't set exclusive = 0 t->m->stateLock->notifyAll(t->systemThread); } break; diff --git a/src/machine.h b/src/machine.h index f00f5a3328..982b4fb086 100644 --- a/src/machine.h +++ b/src/machine.h @@ -1972,6 +1972,7 @@ addThread(Thread* t, Thread* p) ACQUIRE_RAW(t, t->m->stateLock); assert(t, p->state == Thread::NoState); + expect(t, t->state == Thread::ActiveState || t->state == Thread::ExclusiveState); p->state = Thread::IdleState; ++ t->m->threadCount;