Skip to content

Commit 46fd683

Browse files
committed
8176567: nsk/jdi/ReferenceType/instances/instances002: TestFailure: Unexpected size of referenceType.instances(nsk.share.jdi.TestInterfaceImplementer1): 11, expected: 10
Reviewed-by: sspitsyn, amenkov
1 parent e314a4c commit 46fd683

File tree

1 file changed

+15
-16
lines changed
  • src/jdk.jdwp.agent/share/native/libjdwp

1 file changed

+15
-16
lines changed

src/jdk.jdwp.agent/share/native/libjdwp/invoker.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -752,7 +752,9 @@ invoker_completeInvokeRequest(jthread thread)
752752
}
753753
id = request->id;
754754
exc = request->exception;
755+
request->exception = NULL;
755756
returnValue = request->returnValue;
757+
request->returnValue.l = NULL;
756758

757759
/* Release return value and exception references, but delay the release
758760
* until after the return packet was sent. */
@@ -790,23 +792,20 @@ invoker_completeInvokeRequest(jthread thread)
790792
(void)outStream_writeValue(env, &out, tag, returnValue);
791793
(void)outStream_writeObjectTag(env, &out, exc);
792794
(void)outStream_writeObjectRef(env, &out, exc);
795+
/*
796+
* Delete potentially saved global references for return value
797+
* and exception. This must be done before sending the reply or
798+
* these objects will briefly be viewable by the debugger as live
799+
* when they shouldn't be.
800+
*/
801+
if (mustReleaseReturnValue && returnValue.l != NULL) {
802+
tossGlobalRef(env, &returnValue.l);
803+
}
804+
if (exc != NULL) {
805+
tossGlobalRef(env, &exc);
806+
}
793807
outStream_sendReply(&out);
794808
}
795-
796-
/*
797-
* Delete potentially saved global references of return value
798-
* and exception
799-
*/
800-
eventHandler_lock(); // for proper lock order
801-
debugMonitorEnter(invokerLock);
802-
if (mustReleaseReturnValue && returnValue.l != NULL) {
803-
tossGlobalRef(env, &returnValue.l);
804-
}
805-
if (exc != NULL) {
806-
tossGlobalRef(env, &exc);
807-
}
808-
debugMonitorExit(invokerLock);
809-
eventHandler_unlock();
810809
}
811810

812811
jboolean

0 commit comments

Comments
 (0)