GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — Fix NPE in AbstractNioChannel.removeReadOp() after concurrent deregistration by seonwooj0810 · Pull Request #17104 · netty/netty Conversation
Contributor
Fixes #17103 Motivation
ModificationMake Result
Added Verification done: built
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…tration
Motivation:
clearReadPending() guards the scheduling of clearReadPendingRunnable with an
isRegistered() check, which reads the "registered" boolean of AbstractChannel.
That boolean and the IoRegistration field of AbstractNioChannel are not updated
atomically together. When a channel is deregistered from a different thread after
the isRegistered() check passed but before the runnable executes on the EventLoop,
doDeregister() has already set the registration field to null. removeReadOp() then
called registration() (which returns the field after an assert) and dereferenced it,
producing a NullPointerException (or an AssertionError when assertions are enabled):
java.lang.NullPointerException
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.removeReadOp(AbstractNioChannel.java:268)
at io.netty.channel.nio.AbstractNioChannel.clearReadPending0(AbstractNioChannel.java:223)
at io.netty.channel.nio.AbstractNioChannel$1.run(AbstractNioChannel.java:66)
...
Modification:
Make removeReadOp() read the registration field directly and null-check it before
use, mirroring the idiom already used by doBeginRead() in the same class.
Result:
removeReadOp() no longer throws when the channel has been deregistered concurrently.
Fixes netty#17103.
normanmaurer
approved these changes
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
✅ All tests passed ✅🏷️ Commit: 271921f Learn more about TestLens at testlens.app. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@seonwooj0810 did you sign our icla yet ? https://netty.io/s/icla |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@normanmaurer Yes — the ICLA for this account (seonwooj0810) has been submitted via https://netty.io/s/icla. If there is a processing delay on your end, please let me know and I can confirm the submission details. Also, thank you both to @normanmaurer and @chrisvest for the approvals on this PR! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@seonwooj0810 The processing should be instant, but I don't see your github username or your email. Did the form properly submit? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@seonwooj0810 please do again... it was not stored for whatever reason |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you both for checking — sorry for the confusion. @chrisvest @normanmaurer The form did not store properly — I apologize for the failed submission. I will re-submit the ICLA at https://netty.io/s/icla immediately. Once it registers, please let me know if anything else is needed on the PR side. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@seonwooj0810 I'm still not seeing it registered, but others have successfully signed in the mean time, so the form works. Maybe try a different browser, or try disabling content blockers or the like. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thank you for checking again, @chrisvest. I apologize for the repeated inconvenience. I will try the form again using a different browser as you suggested. If the submission is still not recorded after that, I will reach out separately to confirm the account details are correct. I will post an update here once the ICLA shows up on your end. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Just resubmitted the ICLA form again (tried a different browser this time as suggested). Please let me know if it's still not showing up on your end. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@seonwooj0810 this worked |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Could not create auto-port PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…tration (#17104) (#17248) Fixes #17103 `clearReadPending()` guards scheduling of `clearReadPendingRunnable` with an `isRegistered()` check, which reads the `registered` boolean of `AbstractChannel`. That boolean and the `IoRegistration registration` field of `AbstractNioChannel` are not updated atomically. When a channel is deregistered from another thread *after* the `isRegistered()` check passed but *before* the runnable runs on the `EventLoop`, `doDeregister()` has already set `registration` to `null`. `removeReadOp()` then obtained the field via `registration()` (which only `assert`s non-null) and dereferenced it, producing the reported `NullPointerException` in production (or an `AssertionError` when assertions are enabled): ``` java.lang.NullPointerException at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.removeReadOp(AbstractNioChannel.java:268) at io.netty.channel.nio.AbstractNioChannel.clearReadPending0(AbstractNioChannel.java:223) at io.netty.channel.nio.AbstractNioChannel$1.run(AbstractNioChannel.java:66) ... ``` Make `removeReadOp()` read the `registration` field directly and null-check it before use, mirroring the null-safe idiom already used by `doBeginRead()` in the same class. Behaviour is unchanged when the channel is still registered. `removeReadOp()` no longer throws when the channel has been deregistered concurrently. Added `AbstractNioChannelTest#testRemoveReadOpDoesNotThrowAfterDeregister`, which registers a `NioSocketChannel`, deregisters it (clearing the registration), then invokes `removeReadOp()`. The test fails on the current code (NPE / AssertionError at `AbstractNioChannel.java:264` → `registration()` at `:156`) and passes with this change. Verification done: built `transport` (+ deps) and ran the new regression test (fails before / passes after the fix); ran the existing `NioEventLoopTest` (13 tests, all green); ran the project checkstyle execution (`checkstyle:check@check-style`, no violations). Co-authored-by: Norman Maurer <[email protected]> Co-authored-by: seonwoojung <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
NPE when clearing read pending status of a NIO channel
There was an error while loading. Please reload this page.