From: Ian Rogers Date: Sat, 28 Jun 2014 00:32:56 +0000 (-0700) Subject: Avoid segvs if LOG(FATAL) is called during runtime start-up. X-Git-Tag: android-x86-6.0-r1~3200^2~87^2^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4e14e721055eeeb42b06ad231bce930f3e1c1728;p=android-x86%2Fart.git 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 8aa7ea18d..53ddcca46 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -241,16 +241,22 @@ struct AbortState { } 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); } };