GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix NPE in AbstractNioChannel.removeReadOp() after concurrent deregistration by seonwooj0810 · Pull Request #17104 · netty/netty

Conversation

@seonwooj0810

@seonwooj0810 seonwooj0810 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #17103

Motivation

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 asserts 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)
    ...

Modification

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.

Result

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).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@seonwooj0810
Fix NPE in AbstractNioChannel.removeReadOp() after concurrent deregis…
e730d46
…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
normanmaurer approved these changes Jul 16, 2026
View reviewed changes
@normanmaurer
Merge branch '4.2' into fix/17103-removereadop-npe-after-deregister
d1268c8
@normanmaurer normanmaurer added this to the 4.2.17.Final milestone Jul 18, 2026
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Jul 18, 2026
@seonwooj0810

seonwooj0810 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the approval, @normanmaurer. Is anything still blocking the merge here, or is it just waiting on a batch? Happy to rebase if that would help.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
Merge branch '4.2' into fix/17103-removereadop-npe-after-deregister
271921f
@testlens-app

testlens-app Bot commented Aug 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 271921f
▶️ Tests: 0 executed
⚪️ Checks: 18/18 completed


Learn more about TestLens at testlens.app.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer
normanmaurer approved these changes Aug 3, 2026
View reviewed changes
@normanmaurer

normanmaurer commented Aug 3, 2026

Copy link
Copy Markdown
Member

@seonwooj0810 did you sign our icla yet ? https://netty.io/s/icla

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chrisvest
chrisvest approved these changes Aug 3, 2026
View reviewed changes
@seonwooj0810

seonwooj0810 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest

chrisvest commented Aug 4, 2026

Copy link
Copy Markdown
Member

@seonwooj0810 The processing should be instant, but I don't see your github username or your email. Did the form properly submit?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Aug 4, 2026

Copy link
Copy Markdown
Member

@seonwooj0810 please do again... it was not stored for whatever reason

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest chrisvest modified the milestones: 4.2.17.Final, 4.2.18.Final Aug 4, 2026
@seonwooj0810

seonwooj0810 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chrisvest

chrisvest commented Aug 6, 2026

Copy link
Copy Markdown
Member

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seonwooj0810

seonwooj0810 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seonwooj0810

seonwooj0810 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Aug 9, 2026

Copy link
Copy Markdown
Member

@seonwooj0810 this worked

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Aug 9, 2026
@normanmaurer
normanmaurer merged commit f8e1152 into netty:4.2 Aug 9, 2026
34 of 35 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot

netty-project-bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Could not create auto-port PR.
Got conflicts when cherry-picking onto 5.0.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer added a commit that referenced this pull request Aug 10, 2026
@normanmaurer @seonwooj0810
Fix NPE in AbstractNioChannel.removeReadOp() after concurrent deregis…
4da8e29
…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]>
@lhotari lhotari mentioned this pull request Sep 10, 2026
[fix][sec] Upgrade Netty to 4.2.18 to address several CVEs and bugs apache/pulsar#26514
Merged
2 of 11 tasks
@chrisvest chrisvest removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Sep 28, 2026
@normanmaurer normanmaurer mentioned this pull request Oct 1, 2026
child5 #17695
Closed
@normanmaurer normanmaurer mentioned this pull request Oct 26, 2026
crisp nova cceda091 #18109
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chrisvest chrisvest chrisvest approved these changes
@normanmaurer normanmaurer normanmaurer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.18.Final

Development

Successfully merging this pull request may close these issues.

NPE when clearing read pending status of a NIO channel

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@seonwooj0810 @normanmaurer @chrisvest @netty-project-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.