Fix thread hang
- Primary problem was ScopedThreadListLock was releasing heap lock in constructor instead of destructor
- Secondary problem was ScopedThreadListLock should not be used with Mutex::Wait
- Added Thread.getStackTrace case to ThreadStress that reproduces YouTube problem
- Added Mutex::GetDepth and related methods that were useful in diagnoising this issue
Change-Id: I1bdc7245e9b411378b98f4dcf498ad66eb96366d
diff --git a/src/heap.h b/src/heap.h
index 6b056a2..2e9aa35 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -22,6 +22,7 @@
#include "card_table.h"
#include "globals.h"
#include "heap_bitmap.h"
+#include "mutex.h"
#include "offsets.h"
#define VERIFY_OBJECT_ENABLED 0
@@ -29,7 +30,6 @@
namespace art {
class Class;
-class Mutex;
class Object;
class Space;
class Thread;
@@ -107,6 +107,12 @@
static pid_t GetLockOwner(); // For SignalCatcher.
static void Lock();
static void Unlock();
+ static void AssertLockHeld() {
+ lock_->AssertHeld();
+ }
+ static void AssertLockNotHeld() {
+ lock_->AssertNotHeld();
+ }
static const std::vector<Space*>& GetSpaces() {
return spaces_;