Skip to content

sed_test: the input is in the pipe before sed runs - #1055

Merged
pdfinn merged 1 commit into
masterfrom
claude/sed-test-input-race
Nov 3, 2026
Merged

pdfinn merged 1 commit into
masterfrom
claude/sed-test-input-race

Conversation

@pdfinn

@pdfinn pdfinn commented Nov 3, 2026

Copy link
Copy Markdown
Member

Summary

sed_test's ShortScripts failed in Linux AMD64 Build & Test on #1054, which does not touch sed. The log has only --- FAIL: ShortScripts and the address line, with no assertion message. The cause is a race in the test.

  1. runsed() spawned sed on a pipe and only then wrote abc\n into it.
  2. Some scripts are refused before sed reads anything: an unclosed s/, a lone { or }, : with no label. For those, sed can exit and close the read end before step 1's write.
  3. emu/port/devpipe.c's pipewrite then kills the writer, which is the test itself, with write on closed pipe.
  4. run() catches that as a failure with no message.

Unclosed has the same exposure.

Changes

  • tests/sed_test.b, runsed(): the input is written, and the write end dropped, before sed is spawned. The test still holds the read end at that point, and the pipe buffers the 4 bytes, so sed can't close the pipe under the write. A short write is reported as crash: cannot write input rather than passing silently.

Testing

Linux AMD64, headless build.

  • Before the fix: 16/16 passes (-c1 and -c0, 8 each). It is timing-dependent, which is why it rarely shows.
  • Before the fix, with a 50 ms sleep before the write: ShortScripts and Unclosed fail on every run, with the same bare FAIL as CI.
  • After the fix: passes under -c1 and -c0. It still passes with a 50 ms sleep left in after the spawn.
  • /tests/runner.dis -v: not run in full locally; this PR's CI runs it.

Checklist

  • Code follows the existing style of the file(s) modified
  • No .dis build artifacts committed from appl/ or tests/
  • Documentation updated (if applicable): n/a
  • No secrets, API keys, or credentials included

Generated by Claude Code

runsed() spawned sed on a pipe and then wrote its input. For a script
sed refuses before it reads (an unclosed s/, a lone "{" or "}", ":" with
no label) sed can end and close its end of the pipe first; devpipe's
pipewrite then kills the writer, the test itself, with "write on closed
pipe", and run() counts that as a failure with no message. CI's Linux
AMD64 Build & Test showed exactly that: "--- FAIL: ShortScripts" and the
address line, nothing else, on a PR that does not touch sed.

Locally it passed 16/16 under -c1 and -c0; with a 50 ms sleep before the
write ShortScripts and Unclosed failed every time with the same bare
FAIL. The input is now written while the test still holds the read end,
so nothing sed does can close the pipe under the write; with the same
50 ms window kept after the spawn, it passes under both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0195u6z6W3TbdAx7jg6RqhYy
@pdfinn
pdfinn merged commit 1bea5d1 into master Nov 3, 2026
29 checks passed
@pdfinn
pdfinn deleted the claude/sed-test-input-race branch November 3, 2026 07:13
pdfinn pushed a commit that referenced this pull request Nov 3, 2026
Brings in #1055, the fix for the sed_test race that was this PR's one
red job (Linux AMD64 Build & Test, ShortScripts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0195u6z6W3TbdAx7jg6RqhYy
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.

2 participants