-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8307411: Test java/foreign/channels/TestAsyncSocketChannels.java failed: IllegalStateException: Already closed #13866
Conversation
👋 Welcome back mcimadamore! A progress list of the required criteria for merging this PR into |
@mcimadamore The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great detective work, thanks! I think the fix is good. We already have other tests that try to detect acquire/release issue.
@mcimadamore This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 11 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit f92d095.
Your commit was automatically rebased without conflicts. |
@mcimadamore Pushed as commit f92d095. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This is a tricky intermittent failure on one of our async file channel test.
While the logic of the test is a bit hard to follow, I believe the test is supposed to work as follows:
continueWriting
flag to false (which will cause the handler to stop submitting new write requests).I think, after many hours spent staring the test that, when working as intended, the test logic is correct. Each write is only submitted after the previous one finished, and the test can only end when we see the number of outstanding write to reach 0. For this to happen, we need to execute the handler once when
continueWriting
is set to false (which will cause an asymmetric decrement of the counter from the handler, which will match the asymmetric increment outside the handler, in the main test thread).When trying to reduce the timeout which ensures that write buffers are full, I started hitting the same exception as the one described in the bug report. After some digging, I found that the exception was not caused (as I thought) by some bad synchronization logic which allowed the main test to close the arena before the handlers were actually finished with it. Instead, the failure is caused by the test assertion which checks that the test arena cannot be closed:
This check is bogus: it assumes that the buffers are indeed full, and that some OS write operation cannot progress. In that case, the underlying arena will be kept alive (as the implementation wants to avoid a JVM crash triggered by an OS write on an already freed region of memory).
But, if the buffer is not full at this stage, there is nothing keeping the test arena alive: note that the completion handler executes after the arena acquire/release in
IOUtils
. So, if all write operations complete normally,drop::close
will actually succeed!At this point it's a coint toss as to whether we'll see a message because the copletion handler tries to allocate on an already closed arena, or if we see a message complaining about
drop::close
not failing as expected.While there are other ways to fix this, I think a simple fix is to actually remove the assertion on
drop::close
. Note that if there's a bug in the keepalive logic of the arena, the test would still fail (but with a JVM crash). And, by avoiding a spurious call todrop::close
we make sure that the test always runs as intended whether or not the OS buffers are full.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/13866/head:pull/13866
$ git checkout pull/13866
Update a local copy of the PR:
$ git checkout pull/13866
$ git pull https://git.openjdk.org/jdk.git pull/13866/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 13866
View PR using the GUI difftool:
$ git pr show -t 13866
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/13866.diff
Webrev
Link to Webrev Comment