OSDN Git Service

More native stack dump hardening.
authorElliott Hughes <enh@google.com>
Fri, 12 Apr 2013 18:51:51 +0000 (11:51 -0700)
committerElliott Hughes <enh@google.com>
Fri, 12 Apr 2013 21:54:42 +0000 (14:54 -0700)
Threads just starting up or shutting down might not have any managed
stack frames, leading to a NULL "currFrame" frame pointer in the
interpreter stack.

Bug: 8596028

(cherry picked from commit 46371593812d966c40e1ec4019e3c7c6613046a6)

Change-Id: I0fbc6d422bcae0fd080f7c1a63198755235e9e00

vm/Thread.cpp

index aba98ab..cfc4348 100644 (file)
@@ -3330,7 +3330,12 @@ static bool shouldShowNativeStack(Thread* thread) {
     // state THREAD_SUSPENDED if they're calling back into the VM, or THREAD_MONITOR
     // if they're blocked on a monitor, or one of the thread-startup states if
     // it's early enough in their life cycle (http://b/7432159).
-    const Method* currentMethod = SAVEAREA_FROM_FP(thread->interpSave.curFrame)->method;
+    u4* fp = thread->interpSave.curFrame;
+    if (fp == NULL) {
+        // The thread has no managed frames, so native frames are all there is.
+        return true;
+    }
+    const Method* currentMethod = SAVEAREA_FROM_FP(fp)->method;
     return currentMethod != NULL && dvmIsNativeMethod(currentMethod);
 }