Repository navigation
fix: #795/#796 — 2026-10-18 wave regressions (field-split eligibility, assignment guard byte, jobspec kill notice) - #811
Conversation
caomengxuan666
left a comment
There was a problem hiding this comment.
Code review verdict: REQUEST-CHANGES
The three code fixes are correct and well-evidenced (independently re-verified against WSL GNU bash 5.3.0(1)-release), but the branch is based on a pre-#803 master and its nquote.snap restoration is merge-blocking on current master.
F1 (blocker): nquote.snap restoration reverts the #803 LF-normalization contract and conflicts on current master
- This branch is based on
74e60b01; currentorigin/masterhas since landed c8719d9 (#803), which (a) changedrun_suite_snapshot(tests/regression.rs:461-492 on master) to strip CRLF while copying suite files into the scratch dir, and (b) re-recordednquote.snapincluding thenquote4.subface —alias foo=$'echo foo\n\nquux\n'now expands and prints thefooline (tests/regression/snapshots/nquote.snap:81 on master). git merge-tree --write-tree origin/master cr-811→CONFLICT (content): Merge conflict in tests/regression/snapshots/nquote.snap. Resolving with the PR's side would pin the no-foo(CRLF-era) bytes under the LF-normalizing driver, turningupstream_suite_slice_snapshotsred on the merged tree.- Empirical checks (independent worktrees, both engines built from origin/master and this PR):
- WSL GNU 5.3 on an LF
nquote4.subprintsfoo— thefooface is the GNU-matching one (#803's own 1230-byte evidence; re-confirmed here). - Under a driver-equivalent LF harness, this PR's engine reproduces master's committed
nquote.snapbyte-for-byte (85 lines incl.foo) — the PR's engine changes do not shift this face at all. - The PR branch's test passes only because its base predates the driver change and the CRLF copy keeps the alias face silent — the exact divergence #803 removed.
- WSL GNU 5.3 on an LF
- The PR description's "nquote.snap returns byte-identical to the original GNU-diffed recording (1f30c09)" is byte-true but endorses the pre-#803 bytes; and "the wave's truncation (f7eaebf/0ac17515) was an artifact of the transient breakage" is right about the truncation but the correct rebase target for this file is master's current version, not 1f30c09.
- Fix: rebase onto current master and drop the
nquote.snaphunk entirely. (exp.snap is unaffected: master did not touch it, and the changed face now matches the repo's GNU oracle tests/gnu-compat/upstream-rights/exp.right exactly at that position, with all other divergences pre-existing and untouched.)
F2 (nit): the two new kill tests under-pin the stated contracts (tests/executor_command_chaining/part_036.rs:328-378)
test_kill_jobspec_leaves_no_completion_noticeasserts only the redirected output file; the "no[1]+ Exit 143notice" contract goes to the process stderr, which the in-process harness never captures — a notice regression would not fail this test.- No jobspec-shaped pin exists for
kill -9 %1still announcingKilled(the keep-entry arm this PR promises; issue550's test is pid-shaped) nor forkill %1; wait $!→143(the completed_statuses preservation the new branch relies on). Both behaviors were verified correct vs GNU in this review, but they are un-pinned; one test each would lock them.
F3 (nit): fabricated 143 in the zombie window (src/executor/limit_builtins.rs:120-142)
- The branch fires whenever
kill(2)reports success, stashing128+sigeven if the child had already exited with 0 but was not yet reaped; GNU'swait $!would then report 0 while rubash now reports 143. Narrow race; consider atry_waitprobe before fabricating. - The branch also skips
forget_background_runtime(unlike the wait path, src/executor/job_builtins.rs:906) and leaves the dead child to the boundary reap — benign today because the Windows emulation terminates with exit code128+signal(src/builtins/kill.rs:1491) so the latermark_completedis idempotent, but that invariant is undocumented coupling.
Independently verified (no findings)
- Fix 1 (src/executor/command_words.rs:638-669): unquoted-introducer
${early-returns true; quoted introducer skips the body with brace depth;\'/\"never toggle quote state (lines 617-619), so\"${x}\"classifies like bare${x}and"${a[@]+\"${a[@]}\"}"keeps its no-split classification — matches GNU 5.3 probes (["p] ["q"],<"p><q">, one-lineUnquoted: H H). - Fix 1b (src/executor/command_prepare.rs:4040-4067): escaped quote outside any span → DATA_SQUOTE/DATA_DQUOTE (0x17/0x18) exactly matches the lexer (src/lexer/quotes.rs:380-389); inside spans stays a pair; simulation mismatch still bails safely.
- Fix 2 (src/executor/assignment_expansion.rs:1316-1320, 1350-1354):
strip_ansi_c_ifs_guardis E400-aware (src/executor/markers.rs:831-855) — bare E401 at this boundary can only be the lexer guard (the guard producer writes the marker directly, markers.rs:796-798; user U+E401 arrives E400-escaped), and the drop must precedeappend_expanded_shell_textbecause the splice would E400-encode the guard into an indistinguishable pair.v2len=5 matches GNU. - Fix 3: the silent set {INT, PIPE, TERM, trapped} mirrors
report_pending_signal_notices(src/executor/job_builtins.rs:622-668); GNU probes confirm all four faces (kill %1silent cleanup,kill %1; wait $!→ 143,kill -9 %1→Killed, trapped TERM silent). - Gates: compared failing-target sets on origin/master vs this PR in identical sandboxes — 0 new failures; 4 tests flip red→green (both part_036 kill tests, part_061
test_parameter_plus_allows_newline_word,bashdb_compat::bash_compat_debugger_options_run_init_file_before_script); the ticket-namednested_quoted_guard_class,assignment_positions_store_clean_values,test_parameter_transform_prints_key_value_pairsare red on master and green here.cargo fmt --checkclean; GPL scan clean (MIT repo, no third-party code transcribed); diff scope = 4 src + 4 tests + 2 snapshots, no ride-alongs. - The "recho 污染 2 条假新增" gate note could not be reproduced (snapshots pass with proper helpers); plausible but unverifiable here — and subsumed by F1's snapshot-narrative correction.
caomengxuan666
left a comment
There was a problem hiding this comment.
CR follow-up (re-verified against master@5ace807e / post-#835)
R1 verdict stands: REQUEST-CHANGES with F1 as the only blocker; F2/F3 remain nits. PR head is unchanged (20dce8e); master has advanced by #810-#835. Re-verification performed on the actual merged tree (cr-811 + origin/master, nquote.snap conflict resolved to the master side), including the #812 space-free THIS_SH pin and the #809/#834/#835 background direct-spawn wave:
- F1 re-confirmed, resolution unchanged:
git merge-tree --write-tree origin/master cr-811still conflicts in exactly one file —tests/regression/snapshots/nquote.snap. On the merged tree with master's side kept,upstream_suite_slice_snapshotsis green (all 13 slices: exp from this PR's side, nquote from master's side, under the new THIS_SH-pinned driver). Master's exp.snap is untouched (74e60b0..master diff empty), so the PR's exp.snap hunk applies cleanly and stays. Rebase instruction: keep exp.snap, drop the nquote.snap hunk entirely (master's version wins). The R1 note about the description's "nquote.snap byte-identical to 1f30c09" claim also stands — the no-foobytes are the CRLF-era divergence;foo(nquote4.subalias foo=$'echo foo\n\nquux\n') is the GNU-matching face. - No new failures on current master: same failing-target set compared on origin/master vs the merged tree in identical sandboxes — merged-tree failures are a strict subset (0 new). 3 tests flip red→green on the merged tree (both part_036 kill tests, part_061
test_parameter_plus_allows_newline_word); the other 37 are the pre-existing sandbox-environmental set, identical on both sides. The R1 bashdb flip no longer appears because the #809-#835 wave fixed it on master independently. - Fix faces survive the wave on the merged tree: arrdefault 11/11 (
nested_quoted_guard_class), issue379 12/12 (assignment_positions_store_clean_values), parameter_transform 18/18 (@K), executor_tests part_036 33/33 (kill), part_061 15/15. #809's background direct-spawn gate (compound_exec.rs) does not touchcommand_words.rs's scanner (master's copy at :605 is still the pre-PR version), so there is no semantic coupling. - F2/F3 unchanged: the stderr-capture gap in
test_kill_jobspec_leaves_no_completion_noticeand the missing jobspec-shaped pins (kill -9 %1→Killed,kill %1; wait $!→ 143) are still open; the limit_builtins.rs:120-142 zombie-window fabrication +forget_background_runtimecoupling note still applies (file untouched by master).
Actionable for merge: rebase onto current master; in the nquote.snap conflict take master's side (equivalently: revert this PR's nquote.snap hunk); optionally update the PR description's snapshot narrative. Everything else is approved as-is.
20dce8e to
f3b8a5a
Compare
… state (#795) #789's per-character scan for split-eligible words (raw_word_has_unquoted_parameter_expansion_outside_quotes) skipped the whole ${...} span while hunting for expansions outside quote segments. A braced span IS a parameter expansion: when the dollar introducing it sits outside any quote segment, the word carries an unquoted expansion regardless of what the body contains. Skipping the body wholesale dropped three word classes off the split path: - "${a[@]+"${a[@]}"}"-with-escaped-quotes: the guard fragment's alternate \"${a[@]}\" re-lexes with escaped quotes as DATA (never quote toggles), so it must classify exactly like a bare ${x} and split its joined result: GNU 5.3.0 gives ["p]/[q"], master gave one ["p q"] field. - H${$+<newline>}H - the unquoted expansion result must field-split at the newline: GNU prints 'Unquoted: H H' on one line, master printed two lines. - ${assoc[@]@k} - the transform's trailing separator must fall off through the unquoted field split (GNU drops it unquoted and keeps it in the quoted face). When the introducer itself is quoted ("${x}"), the span's result never field-splits, so the scan keeps skipping the body. The eligibility re-enable also re-armed #743's quoted-segment IFS protection for words whose escaped quotes the marking simulation mis-modeled: the lexer cooks an escaped quote OUTSIDE any quote span to its data-quote marker (single-quote escapes to 0x17, double-quote escapes to 0x18), and the simulation must reproduce that or it bails and a quoted blank loses its protection (a replacement word with escaped-quote affixes plus a quoted trailing space lost that space, part_063). Model the two spellings; span-internal backslashes stay verbatim pairs. Snapshot re-recorded per the tests/regression.rs protocol (this commit is the named engine change): exp.snap's X${c}X face now splits XY/YX under IFS=0x01 exactly like GNU bash (the committed golden had encoded the pre-#789 no-split divergence; WSL GNU 5.3.0(1)-release probe, 2026-10-13). nquote.snap intentionally stays at master's version: its trailing `foo` line is the GNU-consistent nquote4.sub alias face under the #812 suite driver, and the no-foo golden was the CRLF-era divergence already adjudicated in #803 - carrying this fix's transient recording forward would resurrect those bytes. New GNU-verified differential pins: arrdefault_quoted_array_default_regressions:: escaped_quote_guard_class_splits_vs_gnu and parameter_transform_tests:: test_parameter_transform_at_k_trailing_separator_splits_away_unquoted.
…d splice (#796) v2=$'p\nq'$(echo r)s stored 6 characters where GNU bash 5.3.0 stores 5 (p newline q r s): one ANSI_C_IFS_GUARD byte reached the cell. #791 extended the marker zone to cover U+E401 (rubash#735), which re-routes the guard through the mixed command-substitution splice's payload re-encoding: the bare guard crosses append_expanded_shell_text and materializes as an E400-escaped pair, and the assignment funnel's tail strip must then PRESERVE that pair as #735 user data - so the transport carrier survived into storage. The guard is field-split transport (rubash#379), and an assignment value never field-splits, so the boundary that drops it is the fragment boundary BEFORE the payload splice. Strip the bare guard from the prefix and suffix fragments of expand_mixed_command_substitution_assignment. Differential pins (tests/issue379_ansic_blank_between_comsubs_ regressions.rs::assignment_comsub_fragments_store_clean_values, byte-verified against the WSL GNU 5.3.0(1)-release oracle): prefix, suffix and both-adjacent fragments store clean lengths 5/4/5, and the for-list face keeps the decoded newline literal while field-splitting only the substitution output.
kill %1 followed by jobs/wait printed '[1]+ Exit 143 while true; do true; done' where GNU bash 5.3.0 prints nothing: a non-interactive reader suppresses the completion notice of a job the kill builtin itself terminated (jobs.c notify_of_job_status, the DONT_REPORT_SIGINT/SIGPIPE/SIGTERM + trapped arm - nothing printed, the dead job is cleaned up), and #790 (rubash#737) had dropped the jobspec-kill table cleanup to keep wait resolving the signal status. Restore the cleanup with the status-preserving removal: stash the signal status, close the coproc endpoints, drop the entry via remove_job_by_pid_preserve_status. kill %1; jobs lists nothing, no notice fires at the reap boundary, and a pid-shaped wait still resolves 143 through completed_statuses (#737's contract). The signal set follows the DONT_REPORT arm (SIGINT/SIGPIPE/SIGTERM or trapped, the same set report_pending_signal_notices already implements): kill -9 %1 keeps the entry so the async reap still announces Killed (GNU-verified), and pid operands are untouched for the #737 wrapper-death flow. Differential pins (part_036): test_kill_jobspec_leaves_no_completion_ notice and test_kill_pid_operand_then_wait_reports_signal_status, byte-verified against the WSL GNU 5.3.0(1)-release oracle.
f3b8a5a to
6b9065f
Compare
|
F1 resolved — force-pushed
F2/F3 acknowledged as non-blocking; will pick them up with the next face touching those spots. |
Closes #795, closes #796.
Rebased on master (bd4f703, post-#836). Three byte-level regressions from the 2026-10-18 PR wave, each root-caused below and pinned with differential tests byte-verified against the WSL GNU bash 5.3.0(1)-release oracle.
CR round update (F1 resolution): rebased onto current master; the nquote.snap conflict is resolved by keeping master's version (this PR carries NO nquote.snap change — only the exp.snap re-record). The corrected snapshot story: master's trailing
fooline in nquote4.sub is the GNU-consistent alias face under the #812 suite driver; the earlier no-foogolden was the CRLF-era divergence adjudicated in #803.upstream_suite_slice_snapshotsis fully green (13 slices) on this branch.1. Field-split eligibility: a
${...}span IS an unquoted parameter expansion (#795 both cases, #796 @k face)#789's per-character scan
raw_word_has_unquoted_parameter_expansion_outside_quotesskipped the whole${...}body while hunting for expansions outside quote segments — hiding the very expansion the span performs. When the$introducing the span sits outside any quote segment, the word carries an unquoted expansion regardless of the body (quotes inside are the expansion's own word syntax). That lost the field split for three faces:for f in "${a[@]+\"${a[@]}\"}"["p] [q"]["p q"]["p] [q"]echo Unquoted: H${$+<nl>}HUnquoted: H H(one line)echo assoc:${assoc[@]@K}Quoted introducers (
"${x}") keep skipping the body — a quoted result never field-splits.Re-enabling the split re-armed #743's quoted-segment IFS marking for words whose escaped quotes the marking simulation mis-modeled (the lexer cooks an escaped quote outside any quote span to its data-quote marker): the simulation now reproduces both spellings, restoring part_063's quoted-trailing-space pin.
Snapshot:
exp.snapre-recorded per the tests/regression.rs protocol (this PR is the named engine change) — theX${c}Xface now splitsXY/YXunder IFS=0x01 exactly like GNU (the committed golden had encoded the pre-#789 no-split divergence).2. Assignment guard byte (#796 case 1)
v2=$'p\nq'$(echo r)sstored 6 characters (GNU: 5,p \n q r s). #791's marker-zone extension made the mixed command-substitution splice re-encode the bare ANSI_C_IFS_GUARD as anE400 E401pair — indistinguishable from #735 user data, which the assignment tail strip must preserve. The guard is split transport and an assignment value never splits, so the drop now happens at the fragment boundary BEFORE the splice (prefix + suffix).3. Jobspec kill completion notice (#796 case 3)
kill %1+jobs/waitprinted ``[1]+ Exit 143 while true; do true; done'' where GNU prints nothing: a non-interactive reader suppresses the notice of a job the kill builtin itself terminated (jobs.c notify_of_job_status, DONT_REPORT_SIGINT/SIGPIPE/SIGTERM + trapped arm) and cleans the dead job up. Restored with the status-preserving removal:kill %1; jobslists nothing, no notice at the wait, a pid-shaped `wait $!` still resolves 143 (#737's contract), and `kill -9 %1` keeps the entry so the reap still announces `Killed` (GNU-verified).Differential evidence (before → after vs GNU)
<"p><q"><"p q"><"p><q">${$+<nl>}unquotedUnquoted: H HUnquoted: H\nHUnquoted: H Hlen=5len=6(bare U+E401 in cell)len=5${assoc[@]@K}unquotedassoc:two "beta" one "alpha"${assoc[@]@K}quotedkill:0onlykill:0+[1]+ Exit 143 ...kill:0onlys:143s:143s:143New pins:
escaped_quote_guard_class_splits_vs_gnu,assignment_comsub_fragments_store_clean_values,test_parameter_transform_at_k_trailing_separator_splits_away_unquoted,test_kill_jobspec_leaves_no_completion_notice,test_kill_pid_operand_then_wait_reports_signal_status; the ten ticket-named pinned tests are green.Scope notes
${a[@]+\"'...\"}-style doubly-nested alternates and the non-whitespace-IFS nested-guard face diverge from GNU on master too (pre-wave); untouched — separate issues if wanted.cargo fmtclean (hook-verified); rebased on current master.