Skip to content

WIP: jobs-small — coproc assignment-bang admission (#1983) + post-SIGINT first-line eat (#1997) - #2013

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/1997-1983-jobs-small
Oct 29, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/1997-1983-jobs-small

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Two-issue jobs-small batch, one commit per issue. Draft; NOT to be merged by the author.

6f3b78f — #1983: coproc assignment first word exempts the index-1 ! rejection

GNU's lexer returns an assignment-shaped first word as ASSIGNMENT_WORD, and parse.y:5899 reserved_word_acceptable has no ASSIGNMENT_WORD in its accept set, so a ! after coproc X=1 never becomes BANG — it lexes as a plain WORD and lands as the child command's name (GNU bash 5.3.20 oracle: child reports !: command not found, script rc 0). The #1693 implementation of the #1652 rejection fired for every one-word collection, so the GNU-legal spaced shape coproc X=1 ! echo hi was wrongly rejected rc 2.

Fix: exempt assignment-shaped first words (name / name[subscript], optional +, then =), judged on the raw spelling (a quoted name is not an assignment word in GNU either). Non-name shapes (9a=1, a-b=1) stay WORDs and keep the rc-2 rejection. Judgment shape first measured in the #1712 line's 537e177. Includes the E0282-driven explicit Vec<WordMetadata> annotation (the exemption reads [0].raw before the first push).

Pins: tests/issue1983_coproc_assignment_bang_regressions.rs (4 tests; parse-admission face only — the coproc wait status after the output fd drains is a separate pre-existing reap-face race, deliberately not pinned). Existing #1652 pins stay green (6/6 locally).

Fixes #1983

198744e — #1997: flush the #1639 SIGINT unwind mark on Err unit ends too

The fg_sigint_unwind mark was flushed at the end of an input unit only when the unit ended Ok. When the unit ended in Err — the post-command boundary poll adjudicating the shell's own unconsumed SIGINT delivery into ExitCode(130) after the foreground wait had already set the mark — the mark survived into the next unit and ate its first line (no execution, $? stuck at 130). Captured live with an instrumented build (WAIT-OK -> mark set -> in-unit boundary-poll Err -> prompt -> mark converting at the next unit's list top; 1/220 traced cycles plus 1/40 on the uninstrumented build, load-dependent). GNU consumes the interrupt in the executing list (jobs.c ADDINTERRUPT -> eval.c:111 DISCARD); it can never reach a later line.

Fix: unconditional mem::take at the reader-level flush. Ok path converts to SigintUnwind as before; Err path already ends with the interrupt's own verdict. #1639's same-line discard untouched; its pins (7 + 3) stay green, as do #1662's 4 and #1825's 2 (local runs; one contention flake each for 1825-trapped / 1997-group during a parallel PTY matrix, both green on isolated re-runs).

Pins: tests/issue1997_sigint_first_line_regressions.rs (setsid + group-delivery shapes, FIRST_130 -> SECOND_0 required every cycle). Post-fix PTY matrix: 160/160 cycles correct under strict classification.

Fixes #1997

Gate routing (2026-10-29 house rule)

  • lib + regression name-sets, cross-target cargo check --tests: this PR's CI.
  • CI-unexecuted pin targets (1639/1640/1662/1825/1652/1983/1997): local runs — all green (see above).
  • PTY matrix + diffcorpus: local.
  • Known unrelated CI red: niubash builds against this tree fails on the two repos' docs/api-ledger.md copy drift (byte 371) — also red on other branches today (fix/1903, fix/netopen-family, feat/s5); not this batch.

…ection (rubash#1983)

GNU's lexer returns an assignment-shaped first word as
ASSIGNMENT_WORD, and parse.y:5899 reserved_word_acceptable has no
ASSIGNMENT_WORD in its accept set, so a `!` after `coproc X=1`
never becomes BANG — it lexes as a plain WORD and lands as the
child command's name (GNU bash 5.3.20: the child reports
`!: command not found`, script rc 0). The #1693 implementation of
the #1652 rejection fired for every one-word collection, so the
GNU-legal spaced shape `coproc X=1 ! echo hi` was rejected rc 2.

Exempt assignment-shaped first words (name / name[subscript],
optional `+`, then `=`), judged on the raw spelling — a quoted
name is not an assignment word in GNU either. Non-name shapes
(`9a=1`, `a-b=1`) stay WORDs and keep the rc-2 rejection. The
word_metadata Vec gets an explicit element type: the exemption
reads [0].raw before the first push, which leaves the element
type ambiguous to inference (E0282). Judgment shape first
measured in the #1712 line's 537e177.

Regression pins: tests/issue1983_coproc_assignment_bang_regressions.rs
(X=1 / a+=1 / _a9= spaced forms, a[1]=x subscript form, 9a=1 /
a-b=1 negative controls, glued X=1! control). The pins assert the
parse-admission face only; the coproc wait status after the
output fd drains is a separate, pre-existing reap-face race
(GNU deterministically reports 0 there) and is deliberately not
pinned here.
@caomengxuan666
caomengxuan666 force-pushed the fix/1997-1983-jobs-small branch from 828e2b7 to 198744e Compare October 29, 2026 04:18
@caomengxuan666 caomengxuan666 changed the title WIP: jobs-small — coproc assignment-bang admission (#1983); post-SIGINT line eat (#1997, in progress) WIP: jobs-small — coproc assignment-bang admission (#1983) + post-SIGINT first-line eat (#1997) Oct 29, 2026
…o (rubash#1997)

The fg_sigint_unwind mark was flushed at the end of an input unit
only when the unit ended Ok. When the unit ended in Err instead —
the post-command boundary poll adjudicating the shell's own
unconsumed SIGINT delivery into ExitCode(130) after the
foreground wait had already set the mark — the mark survived
into the next input unit, whose first boundary converted it:
the next line was silently discarded without executing, and $?
stayed 130 for the line after it. GNU consumes the interrupt in
the list that was executing when it landed (jobs.c waitchld
ADDINTERRUPT -> eval.c:111 reader DISCARD); it can never
legitimately reach a line read afterwards.

Captured live with an instrumented build (script(1)-grade PTY
discipline via pty.fork, setsid child): WAIT-OK sig=Some(2) ->
mark set -> in-unit boundary-poll Err sig=2 -> prompt -> the
mark converting at the NEXT unit's list top, eating its line
(1 of 220 traced cycles, load-dependent; a further eat in 1 of
40 cycles on the uninstrumented build; the android-signal
cluster's probe7/probe.py captures match this symptom shape).

The take is now unconditional (mem::take): on the Ok path the
mark converts to SigintUnwind exactly as before; on the Err
path the unit already ends with the interrupt's own verdict,
so dropping the mark loses nothing. #1639's same-line discard
is untouched — mid-unit marks still convert at the next command
boundary of the same list, and its pins stay green.

Regression pins: tests/issue1997_sigint_first_line_regressions.rs
(setsid + group-delivery shapes, FIRST_130 -> SECOND_0 sequence
required on every cycle). Post-fix PTY matrix on the same
discipline: 160/160 cycles correct under strict classification.
@caomengxuan666
caomengxuan666 force-pushed the fix/1997-1983-jobs-small branch from 198744e to b41e656 Compare October 29, 2026 04:26
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 29, 2026 04:39
@caomengxuan666
caomengxuan666 merged commit 61473b1 into master Oct 29, 2026
9 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/1997-1983-jobs-small branch October 30, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant