diff options
author | Andreas Gampe <agampe@google.com> | 2015-01-22 19:48:51 -0800 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2015-01-23 15:16:33 -0800 |
commit | 8f1fa100ee037131976c616ec72a6608dccb51e2 (patch) | |
tree | 4df001bf5f7bc441b81c750b5b858f5c912cd6eb /runtime/base | |
parent | 604e2828896fbb8663897d1e75112da7305ead4c (diff) | |
download | art-8f1fa100ee037131976c616ec72a6608dccb51e2.tar.gz art-8f1fa100ee037131976c616ec72a6608dccb51e2.tar.bz2 art-8f1fa100ee037131976c616ec72a6608dccb51e2.zip |
ART: On shutdown, only warn on mutex contention
Do not abort, as daemon threads may still be active.
Bug: 17894429
(cherry picked from commit c0440f69ebf051ff2ffdc00de51005a040014462)
Change-Id: I7c1d50ff8d4a5e150279e703a69c8f2f1d423e6b
Diffstat (limited to 'runtime/base')
-rw-r--r-- | runtime/base/mutex.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc index 17b2ac98c6..945374185a 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -319,19 +319,24 @@ Mutex::Mutex(const char* name, LockLevel level, bool recursive) exclusive_owner_ = 0; } +// Helper to ignore the lock requirement. +static bool IsShuttingDown() NO_THREAD_SAFETY_ANALYSIS { + Runtime* runtime = Runtime::Current(); + return runtime == nullptr || runtime->IsShuttingDownLocked(); +} + Mutex::~Mutex() { + bool shutting_down = IsShuttingDown(); #if ART_USE_FUTEXES if (state_.LoadRelaxed() != 0) { - Runtime* runtime = Runtime::Current(); - bool shutting_down = runtime == nullptr || runtime->IsShuttingDown(Thread::Current()); 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_; - 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_; + if (exclusive_owner_ != 0) { + LOG(shutting_down ? WARNING : FATAL) << "unexpectedly found an owner on unlocked mutex " + << name_; + } + if (num_contenders_.LoadSequentiallyConsistent() != 0) { + LOG(shutting_down ? WARNING : FATAL) << "unexpectedly found a contender on mutex " << name_; } } #else @@ -342,8 +347,6 @@ Mutex::~Mutex() { errno = rc; // TODO: should we just not log at all if shutting down? this could be the logging mutex! MutexLock mu(Thread::Current(), *Locks::runtime_shutdown_lock_); - Runtime* runtime = Runtime::Current(); - bool shutting_down = (runtime == NULL) || runtime->IsShuttingDownLocked(); PLOG(shutting_down ? WARNING : FATAL) << "pthread_mutex_destroy failed for " << name_; } #endif |