tests/gnu-tools.sh dies of SIGPIPE at random and fails test / scripts #37
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/gascitypacks!37
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/gascitypacks-cbz"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes the random
test / scriptsfailure (run 104, job 4193, exit 141) of gascitypacks-cbz, and the places that had the same defect.Cause
tests/gnu-tools.sh:235,first="$(rows | head -n 1)", underset -euo pipefail:headexits after one line, the loop behind it dies of SIGPIPE on its next write, andpipefailmakes that the failure of the line. It depends on timing; 40 local runs passed. A three-line writer with asleepdies with 141 ashead -n 1and passes assed -n 1p.Change
tests/gnu-tools.sh:rows | sed -n 1p, which reads to the end.grep -qin a pipeline goes through agrepqhelper,grep "$@" >/dev/null, informula.sh(18 places),view-beads.sh(9),view-mail.sh(2),worktree.sh(4) andworktree-setup.sh(3).formula.shis the most exposed: it feedsgrep -qabout 30 KB of formula text withprintf, which writes it in several chunks, andpart ... | grep -qFputs anawkbetween the two.head -n 1andhead -1after a writer becamesed -n 1p(formula.sh,gnu-tools.sh,view-mail.sh).awkprograms offormula.shthat calledexit(Part 6's text after the close, Part 2's first fenced block) skip the rest of their input instead; they ran in$(...)underset -e.Places checked
Every shell file in the repository (
tests/*.sh,roles/assets/scripts,roles/commands/*/run.sh,forgejo/assets/scripts,forgejo/commands/*/run.sh,forgejo/doctor, the orders, the formula's embedded shell,.forgejo/workflows), for a writer piped intohead,grep -q/-l/-m,sed ...q,awkwithexit, or areadthat stops early.tests/upgrade.sh:183,188:{ grep -c ...; } | head -n 1. The writer prints one number in one write, so there is nothing forheadto cut off.tests/view-beads.sh:217:grep ... | head -1inside the text of a failure message; its status is not read.roles/agents/operator/overlay/.../settings.json:jq ... | head -n 1 | tr | { read m; ...}, a hook command that runs withoutpipefail, and whose writer prints one line.grep -q,-land-mon a file, not on a pipe (grep -q 'x' "$tmp/frame.0"): nothing writes to them.roles/orforgejo/that a pack runs stops reading early:jq -e/-er,awkandwhile readthere all read to the end. Their pipelines are unchanged.CHANGELOG
An entry under
[Unreleased]/ Fixed. The repository's habit asks one for a change totests/: every earlier commit that touchedtests/carries one. CI's v1 changelog check, built from the v1 tag, reportsvalid=true.Verified
tests/formula.sh,worktree-setup.sh,worktree.sh,gnu-tools.sh,view-beads.shandview-mail.shpass here;formula.shandgnu-tools.shalso 15 times in a row.merge.sh,apply.sh,upgrade.shandpermission-deny.share untouched. I did not wait for CI.Bead: gascitypacks-cbz
Reviewed
f90343f: the SIGPIPE fix in tests/, its merge into maine22b7f9, CI and the full test set, and repeated runs under load.Reviewed head
f90343f, merged into maine22b7f9. Squash merge commit:2a91bb2.What I checked:
| head -n 1exits 141 and| sed -n 1pexits 0;| grep -qexits 141 and| grepqexits 0 on a match and 1 on no match. So everygrepqkeeps the exit statusgrep -qgave, and-F,-xand--are passed through unchanged.awkprograms intests/formula.sh(the text after the close, and the first fenced block) print exactly what theexitversions printed.sed -n 1pgives the same first line thatheadgave.head,grep -q/-l/-m,sed ...q,awk ... exit, a pipe intoread, and loops withbreak. Nothing is missing. The ones that are left are safe:tests/upgrade.sh:183,188(the writer makes one write),tests/view-beads.sh:217(inside a failure message), the Operator's hook in settings.json (no pipefail), and every othergrep -q, which reads a file. In the pack scripts,jq -e,while readandawkall read their input to the end.f90343f: changelog, lint and scripts were all green (run 1618).gc lint ., everytests/*.shthat CI runs, andgo vetandgo testin forgejo/ all passed.tests/gnu-tools.sh: 40/40 passed on an idle machine and 30/30 with 28 busy loops running (load average about 200).5a0731c,897780d) carry none. An entry under Fixed fits the first habit and is harmless.grepqhelper is test scaffolding and does not belong in the Go tool.Nits (no action needed):
tests/formula.shandtests/worktree.shchange from mode 644 to 755, which the description does not mention. It matches the other tests, and CI runs them withbash.grepqhelper is copied into five files.Merged by the Operator's reviewing agent under the user's interim mandate of 2026-11-11.