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 — io_uring generic-FileRegion fallback truncates output when transferTo() emits more bytes than count() · Issue #16829 · netty/netty

io_uring generic-FileRegion fallback truncates output when transferTo() emits more bytes than count() #16829

New issue
Copy link
New issue
Copy link
Closed
Closed
io_uring generic-FileRegion fallback truncates output when transferTo() emits more bytes than count()#16829
Copy link

Description

@LuciferYang
LuciferYang
opened on May 19, 2026
Issue body actions

Expected behavior

When a custom FileRegion implementation's transferTo(WritableByteChannel, long) emits more bytes than count() - transferred() advertises -- for example, an on-the-fly encryption or framing layer whose count() reports the source size while transferTo() writes larger output (ciphertext, framing prefix/trailer, etc.) -- the io_uring transport should deliver every emitted byte to the peer.

Actual behavior

The generic-FileRegion fallback introduced in #16571 sizes the temporary chunk buffer to min(region.count() - region.transferred(), FILE_REGION_MAX_CHUNK_SIZE). That sizing treats count() as an upper bound on transferTo() output. For an over-emitting FileRegion, the chunk buffer is too small: ByteBufWritableByteChannel.write(ByteBuffer) clamps to the writable byte count, returns the clamped count to the region as if those bytes were accepted, and the excess is silently dropped on the floor.

If the implementation then advances transferred() to count() once its source is drained (the usual pattern when wrapping a fixed-size source), the io_uring completion handler treats transferred() >= count() as "done" and removes the entry from the outbound buffer while a portion of the per-call output is still sitting inside the region. The peer sees a partial frame and the connection stalls.

Steps to reproduce

The regression test added in the proposed fix is a self-contained reproducer (SocketFileRegionTest#testFileRegionEmittingMoreThanCount with EmitMoreThanCountFileRegion fixture). The fixture reports count() = 5 while transferTo() writes 20 bytes in one call. Against unpatched io_uring code the transport's 5-byte chunk buffer accepts only 5 of the emitted bytes; the fixture's fail-fast short-write check throws IOException, which surfaces on the write future and fails the test. With the fix applied the receiver observes all 20 bytes.

Minimal yet complete reproducer code (or URL to code)

See SocketFileRegionTest#testFileRegionEmittingMoreThanCount in the proposed fix.

Netty version

4.2.14.Final-SNAPSHOT (and any prior 4.2.x with #16571 applied).

JVM version (e.g. java -version)

Any JVM that supports Netty 4.2.

OS version (e.g. uname -a)

Linux (io_uring transport).

Activity

  1. normanmaurer commented on Jun 12, 2026

    @normanmaurer
    normanmaurer
    on Jun 12, 2026
    Member
    More actions

    Let's close this one as it was a bug in spark

  2. normanmaurer
    closed this as completedon Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.