From a28c827fdb58ec489931d6e70e27818619bc1b75 Mon Sep 17 00:00:00 2001 From: Roland Levillain Date: Fri, 30 Apr 2021 17:09:10 +0100 Subject: Use `quick_exit` instead of `_exit` (except for error handling). Replace every occurrence of `_exit` (for cases other than pure error handling) with `quick_exit`, in order to allow functions registered with `at_quick_exit` to be called before exiting. In particular, this change will allow LLVM's code coverage profile dumping routine to be called before exiting ART processes. Test: mmma art Test: ART tests Bug: 186576313 Change-Id: Ia9b0dbb471e2a26600c8bd23f7567931d050fc9d --- openjdkjvm/OpenjdkJvm.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'openjdkjvm/OpenjdkJvm.cc') diff --git a/openjdkjvm/OpenjdkJvm.cc b/openjdkjvm/OpenjdkJvm.cc index 675a401bb6..18078abdad 100644 --- a/openjdkjvm/OpenjdkJvm.cc +++ b/openjdkjvm/OpenjdkJvm.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -314,8 +315,10 @@ JNIEXPORT __attribute__((noreturn)) void JVM_Exit(jint status) { LOG(INFO) << "System.exit called, status: " << status; art::Runtime::Current()->CallExitHook(status); // Unsafe to call exit() while threads may still be running. They would race - // with static destructors. - _exit(status); + // with static destructors. However, have functions registered with + // `at_quick_exit` (for instance LLVM's code coverage profile dumping routine) + // be called before exiting. + quick_exit(status); } JNIEXPORT jstring JVM_NativeLoad(JNIEnv* env, -- cgit v1.2.3-59-g8ed1b