Skip to content

8345181: (ch) Windows asynchronous channels may return temporary direct buffers to the buffer cache twice (win) #22554

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

Closed
wants to merge 1 commit into from

Conversation

bplb
Copy link
Member

@bplb bplb commented Dec 4, 2024

Due to operations on different threads, the Windows asynchronous channels might try to return the same buffer to the temporary direct buffer cache twice resulting in an attempt to free the same address more than once. This was not a problem before #22339 was integrated, as previously a cleaner had been used to free temporary buffers, and the cleaner did not permit duplicative freeing of the same memory. This change introduces checks in the Windows asynchronous channels to prevent duplicative returns of a buffer to the cache.


Progress

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

Issue

  • JDK-8345181: (ch) Windows asynchronous channels may return temporary direct buffers to the buffer cache twice (win) (Bug - P2)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22554

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 4, 2024

👋 Welcome back bpb! 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 Dec 4, 2024

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

8345181: (ch) Windows asynchronous channels may return temporary direct buffers to the buffer cache twice (win)

Reviewed-by: alanb, michaelm

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 8 new commits pushed to the master branch:

  • 1d3dcdf: 8345433: (fs) Use stream to load FileTypeDetectors in Files.probeContentType
  • 9740c1d: 8333572: Update jpackage.md with info related to WiX v4 and v5 support
  • de3a218: 8345502: Remove doIntersectionPrivilege methods
  • faa109e: 8340580: Characters in Document diagrams not in the middle
  • 6aa7667: 8339535: JVM crashes with -Xshare:dump -XX:+SegmentedCodeCache
  • e1695f6: 8345472: Fix incorrect format instruction for floating point max/min patterns
  • baa6957: 8345507: Fix build of static launcher
  • 79eb77b: 8345486: Reevaluate the classes in java.lang.classfile.components package

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 rfr Pull request is ready for review label Dec 4, 2024
@openjdk
Copy link

openjdk bot commented Dec 4, 2024

@bplb 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 Dec 4, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 4, 2024

Webrevs

@bplb
Copy link
Member Author

bplb commented Dec 4, 2024

In further testing, with this change, CI test tiers 1-3 and 500 repeats of the subset of tests where the failure was observed passed on Windows.

@AlanBateman
Copy link
Contributor

Just more context here. On Windows, when a file or socket handle is associated with an I/O completion port then the outcome may be handled on the initiating thread when the I/O op completes or fails immediately, or I/O completion status is queued. There are cases where it gets handled on the initiating thread but an I/O completion status is also queued. The buffer handled around this is tricky and it seems that since JDK 7, a substituted buffer can been returned to the TL buffer cache more than once. The changes in this PR will ensure can't handle. Future work could be done in this area to simplify several things but not now.

@AlanBateman
Copy link
Contributor

/reviewers 2

@openjdk
Copy link

openjdk bot commented Dec 4, 2024

@AlanBateman
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

I provided the change for this PR so I can't really be the reviewer too. So I've set reviewer to 2. @Michael-Mc-Mahon is going to help review too.

Copy link
Member

@Michael-Mc-Mahon Michael-Mc-Mahon left a comment

Choose a reason for hiding this comment

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

Seems pretty straightforward. Looks fine.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 4, 2024
@bplb
Copy link
Member Author

bplb commented Dec 4, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Dec 4, 2024

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

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 4, 2024

@bplb Pushed as commit ea73e05.

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

@bplb
Copy link
Member Author

bplb commented Dec 4, 2024

Thanks @AlanBateman for the patch and @Michael-Mc-Mahon for the approval!

@bplb bplb deleted the tempbuffer-dupfree-8345181 branch December 4, 2024 21:20
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