On Thu, 18 Jun 2026 23:33:31 GMT, Man Cao <[email protected]> wrote:
> Hi all,
>
> Could anyone review this change contributed by colleague Liz Looney
> <[email protected]>, that fixes a long-standing data race on
> `com.sun.tools.jdi.VirtualMachineImpl.shutdown`?
>
> -Man
>
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK
> Interim AI Policy](https://openjdk.org/legal/ai).
src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java line 160:
> 158: private Object initMonitor = new Object();
> 159: private boolean initComplete = false;
> 160: private volatile boolean shutdown = false;
Although this is an improvement, I don't know that it actually prevents a race
in all cases. In the following code:
private void processBatchedDisposes() {
if (shutdown) {
return;
}
JDWP.VirtualMachine.DisposeObjects.Request[] requests = null;
...
If shutdown is false on the first check but then set true before we send out
the JDWP.VirtualMachine.DisposeObjects.Request, we still have a race that is
really no different than not having seen shutdown being set to true because
it's not volatile. A proper fix requires synchronization.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31582#discussion_r3439595944