<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
Problem Description :
<div class="ContentPasted0">Customer has reported an issue , hang in preClose() method.
</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Analysis & Observation : </div>
<div class="ContentPasted0">The preClose() method internally calls the dup2() system call. If there is a dup2() call on a file descriptor on a thread while another thread is blocked in a read/write operation on the same file descriptor, then the dup2() call
is known to hang. Currently, preClose() experiences a hang because we call dup2() before killing the reader/writer thread(s).
</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Suggested Solution:</div>
<div class="ContentPasted0">The solution is to first kill the reader/writer thread(s) and then do the preClose() sequence. This reordering in the different channel implementations resolves the customer problem as per the testing.
</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">// wait for any outstanding read to complete</div>
<div class="ContentPasted0"> if (blocking) {</div>
<div class="ContentPasted0"> synchronized (stateLock) {</div>
<div class="ContentPasted0"> assert state == ST_CLOSING;</div>
<div class="ContentPasted0"> long th = thread;</div>
<div class="ContentPasted0"> if (th != 0) {</div>
<div class="ContentPasted0"> nd.preClose(fd);</div>
<div class="ContentPasted0"> NativeThread.signal(th);</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">The above code is changed to </div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0"> // wait for any outstanding read to complete</div>
<div class="ContentPasted0"> if (blocking) {</div>
<div class="ContentPasted0"> synchronized (stateLock) {</div>
<div class="ContentPasted0"> assert state == ST_CLOSING;</div>
<div class="ContentPasted0"> long th = thread;</div>
<div class="ContentPasted0"> if (th != 0) {</div>
<div class="ContentPasted0"> NativeThread.signal(th);</div>
<div class="ContentPasted0"> nd.preClose(fd);</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Releases:</div>
<div class="ContentPasted0">OpenJDK11 & OpenJDK17 the issue is seen. In OpenJDK21 the issue is not seen.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Next steps: </div>
<div class="ContentPasted0">We want to take the above mentioned fix to OpenJDK but unfortunately we are seeing the below issue.</div>
<div class="ContentPasted0">* The customer has confirmed that the issue is not reproducible in OpenJDK dev branch</div>
<div class="ContentPasted0">* We have not been successful in creating a java reproducer even after spending a considerable amount of time.</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">Please review and suggest if the above understanding is right and we shall take the fix to OpenJDK17 and backport to OpenJDK11.
</div>
<div><br class="ContentPasted0">
</div>
<br>
</div>
</body>
</html>