From 6196f619386dce13c0d9aae6749ba68d17411c97 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 20 Aug 2009 08:49:01 -0600 Subject: [PATCH] clear Thread::javaThread before entering zombie state, since clearing it in Thread::dispose is too late - the reference may already be invalid since we don't visit GC roots for zombie threads --- src/jnienv.cpp | 3 +++ src/machine.cpp | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 7e6316f025..11d4e42e34 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -53,6 +53,9 @@ DetachCurrentThread(Machine* m) ACQUIRE_RAW(t, t->m->stateLock); enter(t, Thread::ActiveState); + + threadPeer(t, t->javaThread) = 0; + enter(t, Thread::ZombieState); t->state = Thread::JoinedState; diff --git a/src/machine.cpp b/src/machine.cpp index 6e046843d0..fdbe8ed029 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2201,6 +2201,7 @@ Thread::exit() if (m->liveCount == 1) { turnOffTheLights(this); } else { + threadPeer(this, javaThread) = 0; enter(this, Thread::ZombieState); } } @@ -2209,8 +2210,6 @@ Thread::exit() void Thread::dispose() { - threadPeer(this, javaThread) = 0; - if (systemThread) { systemThread->dispose(); }