diff options
Diffstat (limited to 'runtime/base/mutex.cc')
| -rw-r--r-- | runtime/base/mutex.cc | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc index 49579886fd..a4eb318d4c 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -209,7 +209,9 @@ void BaseMutex::CheckSafeToWait(Thread* self) { } } } - CHECK(!bad_mutexes_held); + if (gAborting == 0) { // Avoid recursive aborts. + CHECK(!bad_mutexes_held); + } } } @@ -325,8 +327,12 @@ Mutex::~Mutex() { LOG(shutting_down ? WARNING : FATAL) << "destroying mutex with owner: " << exclusive_owner_; } else { CHECK_EQ(exclusive_owner_, 0U) << "unexpectedly found an owner on unlocked mutex " << name_; - CHECK_EQ(num_contenders_.LoadSequentiallyConsistent(), 0) - << "unexpectedly found a contender on mutex " << name_; + if (level_ != kMonitorLock) { + // Only check the lock level for non monitor locks since we may still have java threads + // waiting on monitors. + CHECK_EQ(num_contenders_.LoadSequentiallyConsistent(), 0) + << "unexpectedly found a contender on mutex " << name_; + } } #else // We can't use CHECK_MUTEX_CALL here because on shutdown a suspended daemon thread @@ -428,7 +434,17 @@ bool Mutex::ExclusiveTryLock(Thread* self) { } void Mutex::ExclusiveUnlock(Thread* self) { - DCHECK(self == NULL || self == Thread::Current()); + if (kIsDebugBuild && self != nullptr && self != Thread::Current()) { + std::string name1 = "<null>"; + std::string name2 = "<null>"; + if (self != nullptr) { + self->GetThreadName(name1); + } + if (Thread::Current() != nullptr) { + Thread::Current()->GetThreadName(name2); + } + LOG(FATAL) << name1 << " " << name2; + } AssertHeld(self); DCHECK_NE(exclusive_owner_, 0U); recursion_count_--; |