ART: Rewrite Runtime fault message to be lock-free
To avoid the lock in a general header, rewrite the fault message
(that is almost unused) to be lock-free. Store the string as a
heap object owned by Runtime.
Bug: 119869270
Test: mmma art
Test: m test-art-host
Change-Id: Ib1e027a1543c46d25953119f05792f0e874d6a3d
diff --git a/runtime/runtime_common.cc b/runtime/runtime_common.cc
index eae2505..5676577 100644
--- a/runtime/runtime_common.cc
+++ b/runtime/runtime_common.cc
@@ -371,6 +371,11 @@
#pragma GCC diagnostic ignored "-Wframe-larger-than="
#endif
+std::string GetFaultMessageForAbortLogging() {
+ Runtime* runtime = Runtime::Current();
+ return (runtime != nullptr) ? runtime->GetFaultMessage() : "";
+}
+
static void HandleUnexpectedSignalCommonDump(int signal_number,
siginfo_t* info,
void* raw_context,
@@ -427,9 +432,9 @@
}
if (dump_on_stderr) {
- std::cerr << "Fault message: " << runtime->GetFaultMessage() << std::endl;
+ std::cerr << "Fault message: " << GetFaultMessageForAbortLogging() << std::endl;
} else {
- LOG(FATAL_WITHOUT_ABORT) << "Fault message: " << runtime->GetFaultMessage();
+ LOG(FATAL_WITHOUT_ABORT) << "Fault message: " << GetFaultMessageForAbortLogging();
}
}
}