From 9fd470f87342dfe974c8ec8c74239a547e768650 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Fri, 18 Nov 2016 17:21:12 -0800 Subject: [PATCH] ART: Extend DumpRecursiveAbort Accept recursive dump request for deeper recursions. Otherwise, two or more threads aborting concurrently would ensure that there are no dumps. Test: m test-art-host Change-Id: Ib82d64cceba0de89e352d9b15bcd5708db82498c --- runtime/runtime.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 771ac273f..1490f05a7 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -372,9 +372,7 @@ struct AbortState { void Dump(std::ostream& os) const { if (gAborting > 1) { os << "Runtime aborting --- recursively, so no thread-specific detail!\n"; - if (gAborting == 2) { - DumpRecursiveAbort(os); - } + DumpRecursiveAbort(os); return; } gAborting++; @@ -434,8 +432,17 @@ struct AbortState { // For recursive aborts. void DumpRecursiveAbort(std::ostream& os) const NO_THREAD_SAFETY_ANALYSIS { - // The only thing we'll attempt is dumping the native stack of the current thread. - DumpNativeStack(os, GetTid()); + // The only thing we'll attempt is dumping the native stack of the current thread. We will only + // try this if we haven't exceeded an arbitrary amount of recursions, to recover and actually + // die. + // Note: as we're using a global counter for the recursive abort detection, there is a potential + // race here and it is not OK to just print when the counter is "2" (one from + // Runtime::Abort(), one from previous Dump() call). Use a number that seems large enough. + static constexpr size_t kOnlyPrintWhenRecursionLessThan = 100u; + if (gAborting < kOnlyPrintWhenRecursionLessThan) { + gAborting++; + DumpNativeStack(os, GetTid()); + } } }; -- 2.11.0