OSDN Git Service

Fixing a crash when doing lock profiling
authorMattias Petersson <mattias.petersson@sonyericsson.com>
Tue, 5 Jun 2012 08:43:01 +0000 (10:43 +0200)
committerJohan Redestig <johan.redestig@sonymobile.com>
Tue, 5 Jun 2012 08:43:01 +0000 (10:43 +0200)
This is a fix for a crash that can happen when logging Contention
events. This logging is performed when lock profiling is enabled.
This is by default enabled on userdebug builds. The crash happened
when a thread was being destroyed. When a thread is being
destroyed it is normal that the frame depth is zero, and thus the
current frame is null. logContentionEvent() requires that the
current frame is not null, or it will crash.

The fix is to check if the current frame is null.

Change-Id: I4c2b9ad94b663398645497fdffa1ec6f7ea86a51

vm/Sync.cpp

index 80cc6af..eea5116 100644 (file)
@@ -276,6 +276,11 @@ static void logContentionEvent(Thread *self, u4 waitMs, u4 samplePercent,
     size_t len;
     int fd;
 
+    /* When a thread is being destroyed it is normal that the frame depth is zero */
+    if (self->interpSave.curFrame == NULL) {
+        return;
+    }
+
     saveArea = SAVEAREA_FROM_FP(self->interpSave.curFrame);
     meth = saveArea->method;
     cp = eventBuffer;