diff options
author | 2019-05-31 13:07:26 -0700 | |
---|---|---|
committer | 2019-06-03 17:20:21 +0000 | |
commit | ba26b51e2e74bf8c4f87e99dc60f1cbca033ecac (patch) | |
tree | a3fa191885db25da6f86cf8efa64ce9de03414e2 /runtime/runtime.cc | |
parent | e8e2d00ec05ae561ebc7729cc7029a1dc1e02ee6 (diff) |
ART: Skip all-threads dump on abort if locks are held
The thread-list locks are not recursive. Skip the dump on abort
if the locks are already held. Thread state will still be captured
on-device by a tombstone.
Bug: 134037466
Bug: 134167395
Test: m
Test: m test-art-host-gtest-runtime_test
Change-Id: I15ba38a018a39f1cc12577cdf8fb94876b96bbaa
Diffstat (limited to 'runtime/runtime.cc')
-rw-r--r-- | runtime/runtime.cc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 8a3d5402b2..28ac65e8f9 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -549,13 +549,26 @@ struct AbortState { if (runtime != nullptr) { ThreadList* thread_list = runtime->GetThreadList(); if (thread_list != nullptr) { + // Dump requires ThreadListLock and ThreadSuspendCountLock to not be held (they will be + // grabbed). + // TODO(b/134167395): Change Dump to work with the locks held, and have a loop with timeout + // acquiring the locks. bool tll_already_held = Locks::thread_list_lock_->IsExclusiveHeld(self); + bool tscl_already_held = Locks::thread_suspend_count_lock_->IsExclusiveHeld(self); + if (tll_already_held || tscl_already_held) { + os << "Skipping all-threads dump as locks are held:" + << (tll_already_held ? "" : " thread_list_lock") + << (tscl_already_held ? "" : " thread_suspend_count_lock") + << "\n"; + return; + } + bool ml_already_exlusively_held = Locks::mutator_lock_->IsExclusiveHeld(self); + if (ml_already_exlusively_held) { + os << "Skipping all-threads dump as mutator lock is exclusively held."; + } bool ml_already_held = Locks::mutator_lock_->IsSharedHeld(self); - if (!tll_already_held || !ml_already_held) { - os << "Dumping all threads without appropriate locks held:" - << (!tll_already_held ? " thread list lock" : "") - << (!ml_already_held ? " mutator lock" : "") - << "\n"; + if (!ml_already_held) { + os << "Dumping all threads without mutator lock held\n"; } os << "All threads:\n"; thread_list->Dump(os); |