You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2017/10/26 18:20:01 UTC

svn commit: r1813444 - /commons/proper/daemon/trunk/src/native/windows/src/javajni.c

Author: markt
Date: Thu Oct 26 18:20:01 2017
New Revision: 1813444

URL: http://svn.apache.org/viewvc?rev=1813444&view=rev
Log:
Partial fix for DAEMON-302. This addresses JVM crashes with JNI mode.

Modified:
    commons/proper/daemon/trunk/src/native/windows/src/javajni.c

Modified: commons/proper/daemon/trunk/src/native/windows/src/javajni.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/windows/src/javajni.c?rev=1813444&r1=1813443&r2=1813444&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/windows/src/javajni.c (original)
+++ commons/proper/daemon/trunk/src/native/windows/src/javajni.c Thu Oct 26 18:20:01 2017
@@ -473,6 +473,14 @@ static void JNICALL __apxJniExit(jint ex
     return;
 }
 
+static void JNICALL __apxJniAbort()
+{
+    apxLogWrite(APXLOG_MARK_DEBUG "JVM aborted");
+    // Set the exit code to a non-zero value to indicate a non-standard exit
+    vmExitCode = 1;
+    return;
+}
+
 static LPSTR __apxStrIndexA(LPCSTR szStr, int nCh)
 {
     LPSTR pStr;
@@ -660,7 +668,8 @@ apxJavaInitialize(APXHANDLE hJava, LPCST
         if (szClassPath && *szClassPath)
             ++sOptions;
 
-        sOptions++; /* unconditionally set for extraInfo exit */
+        sOptions++; /* unconditionally set for extraInfo exit  */
+        sOptions++; /* unconditionally set for extraInfo abort */
 
         nOptions = __apxMultiSzToJvmOptions(hJava->hPool, lpOptions,
                                             &lpJvmOptions, sOptions);
@@ -685,6 +694,11 @@ apxJavaInitialize(APXHANDLE hJava, LPCST
         lpJvmOptions[nOptions - sOptions].extraInfo    = __apxJniExit;
         --sOptions;
 
+        /* unconditionally add hook for abort in order to store exit code */
+        lpJvmOptions[nOptions - sOptions].optionString = "abort";
+        lpJvmOptions[nOptions - sOptions].extraInfo    = __apxJniAbort;
+        --sOptions;
+
         if (dwMs) {
             wsprintfA(iB[0], "-Xms%dm", dwMs);
             lpJvmOptions[nOptions - sOptions].optionString = iB[0];