Skip to content
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

8280113: (dc) DatagramSocket.receive does not always throw when the channel is closed #12674

Closed
wants to merge 4 commits into from

Conversation

AlanBateman
Copy link
Contributor

@AlanBateman AlanBateman commented Feb 20, 2023

This is an issue with the async close of a DatagramChannel when a thread is blocked in its adaptor's receive method and the underlying socket is non-blocking. The async close causes poll to wakeup and the underlying receive to return 0 so it can't be distinguished from a receive of a zero-length datagram. The channel state needs to be checked to distinguish the two cases so that AsynchronousCloseException can be thrown if the channel has been closed. The bug goes back to JDK 14 when caching of sockaddr structured was introduced.

The test case creates the conditions to exercise the case for both the timed and untimed receive. The bug report is the timed case, which receives two datagrams before attempting a timed receive. The harder case to test is the untimed case so the test uses a virtual thread to force the underlying socket to be non-blocking.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8280113: (dc) DatagramSocket.receive does not always throw when the channel is closed

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12674/head:pull/12674
$ git checkout pull/12674

Update a local copy of the PR:
$ git checkout pull/12674
$ git pull https://git.openjdk.org/jdk pull/12674/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12674

View PR using the GUI difftool:
$ git pr show -t 12674

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12674.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 20, 2023

👋 Welcome back alanb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Feb 20, 2023

@AlanBateman The following label will be automatically applied to this pull request:

  • nio

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.

@openjdk openjdk bot added the nio nio-dev@openjdk.org label Feb 20, 2023
@AlanBateman AlanBateman marked this pull request as ready for review February 20, 2023 19:52
@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 20, 2023
@mlbridge
Copy link

mlbridge bot commented Feb 20, 2023

Webrevs

Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Alan for the updates. This looks good to me.

@openjdk
Copy link

openjdk bot commented Feb 21, 2023

@AlanBateman 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:

8280113: (dc) DatagramSocket.receive does not always throw when the channel is closed

Reviewed-by: jpai, dfuchs

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 1 new commit pushed to the master branch:

  • 10b4cc9: 8301627: System.exit and Runtime.exit debug logging

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 21, 2023
Copy link
Member

@dfuch dfuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Though we can't rule that this test will fail intermittently if it receives stray datagrams sent by other tests / processes. I wonder if the lambda passed to assertThrows should be modified to return to receive if it receives a datagram whose socket address is not null and not that of dc.

@AlanBateman
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Feb 22, 2023

Going to push as commit b6ecca1.
Since your change was applied there have been 15 commits pushed to the master branch:

  • f54e108: 8302831: PPC: compiler/codecache/TestStressCodeBuffers.java fails after JDK-8301819
  • cba817a: 8302838: jabswitch main() should avoid calling exit explicitly
  • 2c52cf0: 8041447: Test javax/swing/dnd/7171812/bug7171812.java fails with java.lang.RuntimeException: Test failed, scroll on drag doesn't work
  • 180b94c: 8302907: [PPC64] Use more constexpr in class Register
  • f319c92: 8303016: Invalid escapes in grep patterns
  • e950b95: 8303033: Build failure with the micro bench mark
  • dcd773a: 8302864: Parallel: Remove PSVirtualSpace::pointer_delta
  • 46f2525: 8299240: rank of JvmtiVTMSTransition_lock can be safepoint
  • ce6de37: 8303010: Add /DEBUG to LDFLAGS for MSVC with ASan
  • 729c26f: 8303020: Remove carriage return in pandoc version string
  • ... and 5 more: https://git.openjdk.org/jdk/compare/db483a38a815f85bd9668749674b5f0f6e4b27b4...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 22, 2023
@openjdk openjdk bot closed this Feb 22, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Feb 22, 2023
@openjdk
Copy link

openjdk bot commented Feb 22, 2023

@AlanBateman Pushed as commit b6ecca1.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated nio nio-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants