From 46bb9a7ab986ef5c9d4afdaedb74dac34e3b1c0c Mon Sep 17 00:00:00 2001 From: Christian Haeubl Date: Mon, 4 Dec 2023 11:46:36 +0100 Subject: [PATCH 1/2] Fix missing headers in libchelper. (cherry picked from commit af68df34e8f61220e8aba171f8486a65d385f69a) --- .../src/com.oracle.svm.native.libchelper/src/getThreadId.c | 1 + .../src/com.oracle.svm.native.libchelper/src/getThreadUserTime.c | 1 + 2 files changed, 2 insertions(+) diff --git a/substratevm/src/com.oracle.svm.native.libchelper/src/getThreadId.c b/substratevm/src/com.oracle.svm.native.libchelper/src/getThreadId.c index 4e60f087cf81..48421bb1ff2a 100644 --- a/substratevm/src/com.oracle.svm.native.libchelper/src/getThreadId.c +++ b/substratevm/src/com.oracle.svm.native.libchelper/src/getThreadId.c @@ -28,6 +28,7 @@ #include #include +#include /* * Based on os::Linux::gettid() from jdk-20-ga, see diff --git a/substratevm/src/com.oracle.svm.native.libchelper/src/getThreadUserTime.c b/substratevm/src/com.oracle.svm.native.libchelper/src/getThreadUserTime.c index e33580a689ab..17836710b5bc 100644 --- a/substratevm/src/com.oracle.svm.native.libchelper/src/getThreadUserTime.c +++ b/substratevm/src/com.oracle.svm.native.libchelper/src/getThreadUserTime.c @@ -26,6 +26,7 @@ #ifdef __linux__ +#include #include #include #include From ae766c3dace847c19f50aa774d560430a2463e43 Mon Sep 17 00:00:00 2001 From: Christian Haeubl Date: Mon, 4 Dec 2023 11:46:58 +0100 Subject: [PATCH 2/2] Fix potentially pending JNI exceptions. (cherry picked from commit 944054914bcf734e07db5b2458230c57b651ece8) --- .../src/com.oracle.svm.native.jvm.posix/src/JvmFuncs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/substratevm/src/com.oracle.svm.native.jvm.posix/src/JvmFuncs.c b/substratevm/src/com.oracle.svm.native.jvm.posix/src/JvmFuncs.c index ad62c918051e..9f20147f7f55 100644 --- a/substratevm/src/com.oracle.svm.native.jvm.posix/src/JvmFuncs.c +++ b/substratevm/src/com.oracle.svm.native.jvm.posix/src/JvmFuncs.c @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include #include @@ -311,10 +311,15 @@ JNIEXPORT jobject JNICALL JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject acti return (*env)->CallObjectMethod(env, action, run); } } + + /* Some error occurred - clear pending exception and try to report the error. */ + (*env)->ExceptionClear(env); + jclass errorClass = (*env)->FindClass(env, "java/lang/InternalError"); if (errorClass != NULL && !(*env)->ExceptionCheck(env)) { (*env)->ThrowNew(env, errorClass, "Could not invoke PrivilegedAction"); } else { + (*env)->ExceptionClear(env); (*env)->FatalError(env, "PrivilegedAction could not be invoked and the error could not be reported"); } return NULL;