-
Bug
-
Resolution: Fixed
-
P4
-
20
-
b24
-
x86_64
-
windows
a number of failures in SocketChannelImpl write method indicating a race condition, but based on the test scenario logic this should not be possible. This indicates that the state examined by ensureOpenAndConnected is possibly inconsistent.
virtual thread attempts a write on a channel, concurrently a platform thread attempt to close channel, BUT only after the virtual thread has "parked". The Closer platform thread polls virtual thread state and then once parked attempts the close after a little pause to raise an AsyncCloseException.
In this instance a CloseChannelException is thrown as the SocketChannelImpl state is not OPEN and CONNECT i.e. CLOSED
As such it would appear that the Closer thread has raced ahead of the writer and closed the channel. For this to happen then the virtual thread has been "parked", but parking only takes place after the invocation ensureOpenAndConnected. Thus highlighting a possible (intermittent) inconsistency in either the state of the SocketChannelImpl at the time of ensureOpenAndConnected, during the write call flow, OR an incosistency of the virtual thread state when read by the Closer platform thread.
test BlockingChannelOps.testSocketChannelWrite(): success
test BlockingChannelOps.testSocketChannelWriteAsyncClose(): failure
java.nio.channels.ClosedChannelException
at java.base/sun.nio.ch.SocketChannelImpl.ensureOpenAndConnected(SocketChannelImpl.java:222)
at java.base/sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:536)
at BlockingChannelOps.lambda$testSocketChannelWriteAsyncClose$7(BlockingChannelOps.java:203)
at jdk.test.lib.thread.VThreadRunner.lambda$run$0(VThreadRunner.java:75)
at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:327)
at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:320)
test BlockingChannelOps.testSocketChannelWriteInterrupt(): success
===============================================
java/nio/channels/vthread/BlockingChannelOps.java#default
Total tests run: 32, Passes: 31, Failures: 1, Skips: 0
virtual thread attempts a write on a channel, concurrently a platform thread attempt to close channel, BUT only after the virtual thread has "parked". The Closer platform thread polls virtual thread state and then once parked attempts the close after a little pause to raise an AsyncCloseException.
In this instance a CloseChannelException is thrown as the SocketChannelImpl state is not OPEN and CONNECT i.e. CLOSED
As such it would appear that the Closer thread has raced ahead of the writer and closed the channel. For this to happen then the virtual thread has been "parked", but parking only takes place after the invocation ensureOpenAndConnected. Thus highlighting a possible (intermittent) inconsistency in either the state of the SocketChannelImpl at the time of ensureOpenAndConnected, during the write call flow, OR an incosistency of the virtual thread state when read by the Closer platform thread.
test BlockingChannelOps.testSocketChannelWrite(): success
test BlockingChannelOps.testSocketChannelWriteAsyncClose(): failure
java.nio.channels.ClosedChannelException
at java.base/sun.nio.ch.SocketChannelImpl.ensureOpenAndConnected(SocketChannelImpl.java:222)
at java.base/sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:536)
at BlockingChannelOps.lambda$testSocketChannelWriteAsyncClose$7(BlockingChannelOps.java:203)
at jdk.test.lib.thread.VThreadRunner.lambda$run$0(VThreadRunner.java:75)
at java.base/java.lang.VirtualThread.run(VirtualThread.java:287)
at java.base/java.lang.VirtualThread$VThreadContinuation.lambda$new$0(VirtualThread.java:174)
at java.base/jdk.internal.vm.Continuation.enter0(Continuation.java:327)
at java.base/jdk.internal.vm.Continuation.enter(Continuation.java:320)
test BlockingChannelOps.testSocketChannelWriteInterrupt(): success
===============================================
java/nio/channels/vthread/BlockingChannelOps.java#default
Total tests run: 32, Passes: 31, Failures: 1, Skips: 0