changeset 54248:6b16292d692b fibers

Fixed incorrect error handling if Fiber.tryMountAndSuspend() returns null.
author cjplummer
date Wed, 06 Mar 2019 18:46:27 -0800
parents 8c96ad06d55c
children d4949ac33b47
files src/jdk.jdwp.agent/share/native/libjdwp/threadControl.c
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jdwp.agent/share/native/libjdwp/threadControl.c	Mon Mar 04 18:32:22 2019 -0800
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/threadControl.c	Wed Mar 06 18:46:27 2019 -0800
@@ -951,7 +951,7 @@
 
     fiberNode = findThread(&runningFibers, fiber);
     if (fiberNode->fiberHelperThread != NULL) {
-        goto done;
+        return fiberNode->fiberHelperThread;
     }
 
     env = getEnv();
@@ -975,15 +975,15 @@
 
     if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
         JNI_FUNC_PTR(env,ExceptionClear)(env);
-        goto done;
+        helperThread = NULL;
     }
 
-    saveGlobalRef(env, helperThread, &(fiberNode->fiberHelperThread));
-
-    /* Start tracking this fiber as a suspended one. */
-    startTrackingSuspendedFiber(fiberNode);
-
- done:
+    if (helperThread != NULL) {
+        saveGlobalRef(env, helperThread, &(fiberNode->fiberHelperThread));
+        /* Start tracking this fiber as a suspended one. */
+        startTrackingSuspendedFiber(fiberNode);
+    }
+
     return fiberNode->fiberHelperThread;
 }
 
@@ -3030,7 +3030,8 @@
                 threadNode->instructionStepMode = JVMTI_ENABLE;
             }
 
-            /* Restore NotifyFramePop. */
+            /* Restore NotifyFramePop. This has to be done even if we are already single stepping
+             * on the carrier thread. */
             {
                 jvmtiError error;
                 jint depth;
@@ -3167,7 +3168,7 @@
                 threadControl_setEventMode(JVMTI_DISABLE, EI_METHOD_ENTRY, thread);
             }
 
-            /* Copy currentStep struct. */
+            /* Copy currentStep struct from the threadNode to the fiberNode and then zero out the threadNode. */
             memcpy(&fiberNode->currentStep, &threadNode->currentStep, sizeof(threadNode->currentStep));
             memset(&threadNode->currentStep, 0, sizeof(threadNode->currentStep));
         }