-
Notifications
You must be signed in to change notification settings - Fork 76
8259636: Check for buffer backed by shared segment kicks in in unexpected places #110
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. |
@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 no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
/integrate |
@mcimadamore Since your change was applied there has been 1 commit pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 17b4db3. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
When support for shared segment was added, we decided to disable support for buffers derived from shared segment in certain async operations, as there's currently no way to make sure that the memory won't be reclaimed while the IO operation is still taking place.
After looking at the code, it seemed like the best place to put the restriction would be sun.nio.ch.DirectBuffer::address() method, since this method is used in a lot of places just before jumping into some piece of JNI code.
While I still stand by that decision, the Netty team has discovered that this decision also affected operations such as creating slices from byte buffers derived from shared segment - this is caused by the fact that one direct buffer constructor (the one for views and slices) is calling the dreaded DirectBuffer::address method.
The fix is simple: just avoid the method call - which is very easy to do in the case of the buffer constructor: in fact this method just returns the value of the
address
field inside theBuffer
class, so we can always cast toBuffer
and then accessaddress
field from there.Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk16 pull/110/head:pull/110
$ git checkout pull/110