Stdin compression reports success after stdout write failures

perfloop-oss/compress · Ignored Failure

https://perfloop.ai/t/oss/case_pn8vx0h37f

Verdict

VERIFIED · settled 2026-11-15 · pull request opened as klauspost/compress#1328

What happened: The check fails before this change and passes with it.

Hypothesis

When standard input is compressed to standard output, compression or output failures are printed but the process still exits successfully. Shell scripts and other callers use that exit status to decide whether output is complete. A zero status can let them accept missing or truncated compressed data. How often this mode encounters output failures is unmeasured.

At revision 7213df05def493d5fb921e472b3f84d92db98aba, main handles the documented `-` argument at lines 108–133. It passes errors from wr.ReadFrom and wr.Close to printErr, then returns normally. Other failed file, option, and output steps use exitErr, which exits with status 2. This finding is limited to the stdin-to-stdout branch; stdin output to an -o file is a separate path.

A new native test, s2/cmd/s2c/perfloop_failure_property_test.go:TestPerfloopOutputFailureStatus, ran main in child processes with one 6-byte input, one CPU, and five seconds per child. The successful stdin-to-stdout control decoded to the original input. With standard output attached to /dev/full, `go test ./s2/cmd/s2c -run '^TestPerfloopOutputFailureStatus$' -count=1 -v` failed with: `stdin-to-stdout write failure exited 0; stderr="\nERROR: write /dev/stdout: no space left on device\n\nERROR: write /dev/stdout: no space left on device\n"`. The scratch test was removed.

The Case proof target is a nonzero exit, with the existing error text, for injected stdout write failures and for a failed stdin read. A successful stdin-to-stdout stream must still exit 0 and decode exactly. The test layout is provisional. Confidence is medium, because the reproduced failure is local but no documented exception for this mode was found.

Open PR https://github.com/klauspost/compress/pull/1297 actively changes stdin output to an -o file and file finalization, so those repairs are omitted here. Its checked head at 6643fe3205b8d0fb3ae89c3338d2b6dc112e4f39 still calls printErr and returns for the stdout case. Contribution guidance uses GitHub pull requests and names no separate review archive. The checkout is shallow, and a bounded public file-history read returned HTTP 403, leaving recent merged history as a gap.

Change to test: Make the stdin-to-stdout branch exit nonzero when reading, compressing, or writing fails, while keeping the existing error text. Preserve successful streaming, exit 0, and decodable output.

Where it lives

perfloop-oss/compress

Evidence

The check fails before this change and passes with it: `For stdin-to-stdout compression with one worker, s2c exits 2 with the existing error text for a closed stdin, a closed stdout during ReadFrom, and a close-only stdout write failure; successful input exits 0 and decodes exactly.`

Checks: 5 of 5 passed. Verification: no defect found.

Timeline