From 7895d554d17309db67737b6750c59d8cece213e3 Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi Date: Thu, 28 Aug 2014 14:55:56 -0700 Subject: Fix an assert failure in art::DumpNativeStack(). When ThreadList::SuspendAll() times out (and aborts), UnsafeLogFatalForThreadSuspendAllTimeout() will call art::DumpNativeStack() but it does not have the mutator lock shared-locked (as it failed while trying to exclusive-lock the mutator lock) and the AssertSharedHeld() on the mutator lock fails. It's an assert failure nested in an time-out abort. This change avoids it by letting it print the native method frame info only if the thread has a shared lock on the mutator lock, as opposed to asserting that it has a shared lock. Change-Id: I17851ebcaa37f4f67086c15243a2cffea3997a02 --- runtime/utils.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'runtime/utils.cc') diff --git a/runtime/utils.cc b/runtime/utils.cc index 55ecc1e40..c359e5803 100644 --- a/runtime/utils.cc +++ b/runtime/utils.cc @@ -1069,10 +1069,6 @@ std::string GetSchedulerGroupName(pid_t tid) { void DumpNativeStack(std::ostream& os, pid_t tid, const char* prefix, mirror::ArtMethod* current_method) { - // We may be called from contexts where current_method is not null, so we must assert this. - if (current_method != nullptr) { - Locks::mutator_lock_->AssertSharedHeld(Thread::Current()); - } #ifdef __linux__ std::unique_ptr backtrace(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, tid)); if (!backtrace->Unwind(0)) { @@ -1104,7 +1100,9 @@ void DumpNativeStack(std::ostream& os, pid_t tid, const char* prefix, if (it->func_offset != 0) { os << "+" << it->func_offset; } - } else if (current_method != nullptr && current_method->IsWithinQuickCode(it->pc)) { + } else if (current_method != nullptr && + Locks::mutator_lock_->IsSharedHeld(Thread::Current()) && + current_method->IsWithinQuickCode(it->pc)) { const void* start_of_code = current_method->GetEntryPointFromQuickCompiledCode(); os << JniLongName(current_method) << "+" << (it->pc - reinterpret_cast(start_of_code)); -- cgit v1.2.3