8134103: JVMTI_ERROR_WRONG_PHASE(112): on checking for an interface
authorsspitsyn
Thu, 02 Mar 2017 16:03:38 -0800
changeset 46841 76a15bd1de0a
parent 46840 6f30145bb877
child 46842 938cbfde7929
8134103: JVMTI_ERROR_WRONG_PHASE(112): on checking for an interface Summary: Add guards to the jdwp agent shutdown Reviewed-by: dholmes, dcubed, dsamersoff
jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugLoop.c
jdk/src/jdk.jdwp.agent/share/native/libjdwp/eventHelper.c
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugLoop.c	Thu Mar 02 09:59:46 2017 +0100
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugLoop.c	Thu Mar 02 16:03:38 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -125,15 +125,13 @@
             jboolean replyToSender = JNI_TRUE;
 
             /*
-             * For VirtualMachine commands we hold the vmDeathLock
+             * For all commands we hold the vmDeathLock
              * while executing and replying to the command. This ensures
-             * that a VM command after VM_DEATH will be allowed to complete
+             * that a command after VM_DEATH will be allowed to complete
              * before the thread posting the VM_DEATH continues VM
              * termination.
              */
-            if (cmd->cmdSet == JDWP_COMMAND_SET(VirtualMachine)){
-                debugMonitorEnter(vmDeathLock);
-            }
+            debugMonitorEnter(vmDeathLock);
 
             /* Initialize the input and output streams */
             inStream_init(&in, p);
@@ -172,9 +170,7 @@
             /*
              * Release the vmDeathLock as the reply has been posted.
              */
-            if (cmd->cmdSet == JDWP_COMMAND_SET(VirtualMachine)){
-               debugMonitorExit(vmDeathLock);
-            }
+            debugMonitorExit(vmDeathLock);
 
             inStream_destroy(&in);
             outStream_destroy(&out);
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/eventHelper.c	Thu Mar 02 09:59:46 2017 +0100
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/eventHelper.c	Thu Mar 02 16:03:38 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -240,10 +240,10 @@
 
         size = commandSize(command);
         /*
-         * Immediately close out any commands enqueued from a
-         * previously attached debugger.
+         * Immediately close out any commands enqueued from
+         * a dead VM or a previously attached debugger.
          */
-        if (command->sessionID != currentSessionID) {
+        if (gdata->vmDead || command->sessionID != currentSessionID) {
             log_debugee_location("dequeueCommand(): command session removal", NULL, NULL, 0);
             completeCommand(command);
             command = NULL;