Convert an assert() into a real test.
We occasionally see an assertion failure on some debug builds that
indicates a thread is being examined by the GC while still running.
This turns the assertion into an always-enabled test with verbose
logging and a VM abort.
diff --git a/vm/Thread.c b/vm/Thread.c
index 67683b5..2ea7bb5 100644
--- a/vm/Thread.c
+++ b/vm/Thread.c
@@ -3793,8 +3793,19 @@
* RUNNING without a suspend-pending check, so this shouldn't cause
* a false-positive.)
*/
- assert(thread->status != THREAD_RUNNING || thread->isSuspended ||
- thread == dvmThreadSelf());
+ if (thread->status == THREAD_RUNNING && !thread->isSuspended &&
+ thread != dvmThreadSelf())
+ {
+ Thread* self = dvmThreadSelf();
+ LOGW("threadid=%d: BUG: GC scanning a running thread (%d)\n",
+ self->threadId, thread->threadId);
+ dvmDumpThread(thread, true);
+ LOGW("Found by:\n");
+ dvmDumpThread(self, false);
+
+ /* continue anyway? */
+ dvmAbort();
+ }
HPROF_SET_GC_SCAN_STATE(HPROF_ROOT_THREAD_OBJECT, thread->threadId);