Skip to content

Port: Fix missing per-entry clamp in IoUringBufferRing.useBuffer (#17568) - #17584

Merged
normanmaurer merged 1 commit into
5.0from
io_uring5
Sep 22, 2026
Merged

normanmaurer merged 1 commit into
5.0from
io_uring5

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

When IORING_RECVSEND_BUNDLE is enabled, a single completion can report
a byte count spanning multiple buffer-ring entries. useBuffer(...)
sliced
the ring entry using that raw total instead of clamping it to the
entry's own writable capacity, so retainedSlice(...) threw an
IndexOutOfBoundsException on the io_uring event-loop thread. The
exception propagated out before the buffer-ring bookkeeping (freeing the
bid, releasing the buffer, decrementing usableBuffers) ran, leaking a
direct buffer and leaving the channel's multishot receive armed to
repeat the fault on every subsequent oversized burst.

Modifications:

Clamp the slice length and writerIndex advance in useBuffer(...) to
byteBuf.writableBytes(), matching the method's documented contract that
callers loop over the remainder via nextBid(...). Add a regression test
exercising useBuffer(...) directly with a read larger than a single
entry's capacity, and switch the test class to AssertJ assumptions.

Result:

useBuffer(...) no longer throws when a bundle completion spans more
than one ring entry.

)

Motivation:

When IORING_RECVSEND_BUNDLE is enabled, a single completion can report
a byte count spanning multiple buffer-ring entries. useBuffer(...)
sliced
the ring entry using that raw total instead of clamping it to the
entry's own writable capacity, so retainedSlice(...) threw an
IndexOutOfBoundsException on the io_uring event-loop thread. The
exception propagated out before the buffer-ring bookkeeping (freeing the
bid, releasing the buffer, decrementing usableBuffers) ran, leaking a
direct buffer and leaving the channel's multishot receive armed to
repeat the fault on every subsequent oversized burst.

Modifications:

Clamp the slice length and writerIndex advance in useBuffer(...) to
byteBuf.writableBytes(), matching the method's documented contract that
callers loop over the remainder via nextBid(...). Add a regression test
exercising useBuffer(...) directly with a read larger than a single
entry's capacity, and switch the test class to AssertJ assumptions.

Result:

useBuffer(...) no longer throws when a bundle completion spans more
than one ring entry.
@testlens-app

testlens-app Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

🚨 TestLens detected 2 failed tests 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Build PR / linux-x86_64-java25-awslc build > Netty/Common

Test Runs Flakiness
SingleThreadEventExecutorTest > testNotSuspendedUntilScheduledTaskIsCancelled() ❌ 1% 🟡

Build PR / linux-x86_64-java25-unsafe-buffer build > Netty/Common

Test Runs Flakiness
SingleThreadEventExecutorTest > testNotSuspendedUntilScheduledTaskIsCancelled() ❌ 1% 🟡

🏷️ Commit: 29c4bc4
▶️ Tests: 151821 executed
⚪️ Checks: 12/12 completed

Test Failures

SingleThreadEventExecutorTest > testNotSuspendedUntilScheduledTaskIsCancelled() (Netty/Common in Build PR / linux-x86_64-java25-awslc build)
org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:31)
	at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:183)
	at io.netty.util.concurrent.SingleThreadEventExecutorTest.testNotSuspendedUntilScheduledTaskIsCancelled(SingleThreadEventExecutorTest.java:196)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
expected actual
true false
SingleThreadEventExecutorTest > testNotSuspendedUntilScheduledTaskIsCancelled() (Netty/Common in Build PR / linux-x86_64-java25-unsafe-buffer build)
java.util.concurrent.TimeoutException: testNotSuspendedUntilScheduledTaskIsCancelled() timed out after 10 seconds
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	Suppressed: java.lang.InterruptedException: sleep interrupted
		at java.base/java.lang.Thread.sleepNanos0(Native Method)
		at java.base/java.lang.Thread.sleepNanos(Thread.java:509)
		at java.base/java.lang.Thread.sleep(Thread.java:540)
		at io.netty.util.concurrent.SingleThreadEventExecutorTest.testNotSuspendedUntilScheduledTaskIsCancelled(SingleThreadEventExecutorTest.java:190)
		at java.base/java.lang.reflect.Method.invoke(Method.java:565)
		... 2 more

Rerun Controls

Select tests to mute in this pull request:

  • SingleThreadEventExecutorTest > testNotSuspendedUntilScheduledTaskIsCancelled()

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app/docs.

@normanmaurer
normanmaurer merged commit 4276f74 into 5.0 Sep 22, 2026
11 of 13 checks passed
@normanmaurer
normanmaurer deleted the io_uring5 branch September 22, 2026 11:50
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant