summaryrefslogtreecommitdiff
path: root/openjdkjvm
diff options
context:
space:
mode:
authorRoland Levillain <rpl@google.com>2021-04-30 17:09:10 +0100
committerRoland Levillain <rpl@google.com>2021-05-07 09:13:03 +0000
commita28c827fdb58ec489931d6e70e27818619bc1b75 (patch)
tree038448d3d8d2922c05296b60b1280c3ed3f596b6 /openjdkjvm
parent7eedd447cb5a4904acf80123ef813a7b8dead9a2 (diff)
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
Diffstat (limited to 'openjdkjvm')
-rw-r--r--openjdkjvm/OpenjdkJvm.cc7
1 files changed, 5 insertions, 2 deletions
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 <dlfcn.h>
#include <limits.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -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,