Skip to content

Preserve clean EOF after non-blocking gzip member - #1293

Open
carrerasdarren-cell wants to merge 1 commit into
madler:developfrom
carrerasdarren-cell:agent/preserve-clean-eof-after-nonblocking-read
Open

Preserve clean EOF after non-blocking gzip member#1293
carrerasdarren-cell wants to merge 1 commit into
madler:developfrom
carrerasdarren-cell:agent/preserve-clean-eof-after-nonblocking-read

Conversation

@carrerasdarren-cell

Copy link
Copy Markdown

Summary

  • wait for input before starting a possible next gzip member on a non-blocking
    reader
  • treat EOF after a completed member as clean when an earlier call observed
    EAGAIN
  • add a one-byte-at-a-time pipe regression for the complete-stream case

Root cause

After Z_STREAM_END, gz_look() immediately switched from LOOK to GZIP
when no compressed input was buffered. On a non-blocking descriptor, an
EAGAIN after the completed trailer therefore committed the state machine to
a next member that might never arrive. If EOF appeared on a later call, the
empty next member was reported as truncated.

The complete uncompressed payload was returned, but gzclose() returned
Z_BUF_ERROR. The regression reproduces this with public APIs and a local
pipe: it feeds one valid member one byte at a time, drains to EAGAIN after
each byte, and closes the writer only after the trailer has been consumed.

The fix asks gz_avail() for input while still in LOOK. An EAGAIN leaves
the reader ready for a delayed concatenated member, while a later EOF with no
bytes is clean.

This is distinct from the open non-blocking write-side reports and patches in
#1256, #1281, #1286, and #1292.

Validation

  • focused regression fails on untouched develop with
    gzclose returned -5 after a complete stream
  • patched Clang ASan/UBSan CMake suite: 12/12 pass
  • traditional static and shared make test pass
  • strict C89 CMake suite: 11/11 pass
  • focused GCC 15 -Wall -Wextra -Werror build and test pass
  • additional local sequence coverage preserves delayed concatenated members,
    transparent reads, trailing garbage handling, and Z_BUF_ERROR for a truly
    truncated trailer

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