Avoid segvs if LOG(FATAL) is called during runtime start-up.
Change-Id: I8b054d0ff2084411ab49ebba83799eb79da879f6
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 8aa7ea1..53ddcca 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -241,16 +241,22 @@
}
void DumpAllThreads(std::ostream& os, Thread* self) NO_THREAD_SAFETY_ANALYSIS {
- bool tll_already_held = Locks::thread_list_lock_->IsExclusiveHeld(self);
- 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";
+ Runtime* runtime = Runtime::Current();
+ if (runtime != nullptr) {
+ ThreadList* thread_list = runtime->GetThreadList();
+ if (thread_list != nullptr) {
+ bool tll_already_held = Locks::thread_list_lock_->IsExclusiveHeld(self);
+ 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";
+ }
+ os << "All threads:\n";
+ thread_list->DumpLocked(os);
+ }
}
- os << "All threads:\n";
- Runtime::Current()->GetThreadList()->DumpLocked(os);
}
};