Skip to content

Commit 748ccc5

Browse files
committedOct 25, 2023
8176567: nsk/jdi/ReferenceType/instances/instances002: TestFailure: Unexpected size of referenceType.instances(nsk.share.jdi.TestInterfaceImplementer1): 11, expected: 10
Backport-of: 46fd683820bb7149c0605a0ba03f59e76de69c16
1 parent ffb4ef2 commit 748ccc5

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

+15-16
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
@@ -753,7 +753,9 @@ invoker_completeInvokeRequest(jthread thread)
753753
}
754754
id = request->id;
755755
exc = request->exception;
756+
request->exception = NULL;
756757
returnValue = request->returnValue;
758+
request->returnValue.l = NULL;
757759

758760
/* Release return value and exception references, but delay the release
759761
* until after the return packet was sent. */
@@ -796,23 +798,20 @@ invoker_completeInvokeRequest(jthread thread)
796798
(void)outStream_writeObjectTag(env, &out, exc);
797799
(void)outStream_writeObjectRef(env, &out, exc);
798800
outStream_sendReply(&out);
801+
/*
802+
* Delete potentially saved global references for return value
803+
* and exception. This must be done before sending the reply or
804+
* these objects will briefly be viewable by the debugger as live
805+
* when they shouldn't be.
806+
*/
807+
if (mustReleaseReturnValue && returnValue.l != NULL) {
808+
tossGlobalRef(env, &returnValue.l);
809+
}
810+
if (exc != NULL) {
811+
tossGlobalRef(env, &exc);
812+
}
799813
outStream_destroy(&out);
800814
}
801-
802-
/*
803-
* Delete potentially saved global references of return value
804-
* and exception
805-
*/
806-
eventHandler_lock(); // for proper lock order
807-
debugMonitorEnter(invokerLock);
808-
if (mustReleaseReturnValue && returnValue.l != NULL) {
809-
tossGlobalRef(env, &returnValue.l);
810-
}
811-
if (exc != NULL) {
812-
tossGlobalRef(env, &exc);
813-
}
814-
debugMonitorExit(invokerLock);
815-
eventHandler_unlock();
816815
}
817816

818817
jboolean

0 commit comments

Comments
 (0)