Skip to content

perf(background): direct spawn for bare-external & bodies (four-commit series, three CR rounds) - #835

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/809-bgwait-direct-spawn
Oct 18, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/809-bgwait-direct-spawn

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #809 (engine half). Four-commit series: direct spawn for bare-external & bodies + CR round 1-3 fixes (restricted arm, raw-scan fallback for expansion-carrying shapes, fd≥3 forwarding, fatal-parameter pre-scan, failglob probe-flag silence) + failglob×background cross-probe. All CR-verified: three CR rounds with reproduction reversals, 40-probe battery, issue_753 17/17, command_chaining 1517 passed. $! = real worker pid (GNU-aligned). Windows wall unchanged (32-core masks); the 2.47x Android win lands via bionic fork-tax elimination — device re-test per the §7 checklist in the investigation report.

…-free — failglob verdicts stay in the child (753.11)

The gate expands the async command's words in the PARENT as an
eligibility probe (background_direct_external_command ->
expand_command_words); on failglob that probe (a) printed `no match` in
the parent — the wrapper fallback's child re-reported it, doubling the
diagnostic on the `&` line — and (b) armed the parent-side expansion
latches (command_expansion_failed, evalerror_pending,
evalerror_failglob_pending, exit_code=1), whose reader-level discard
swallowed the rest of the launch line (`set -- /no/such/*.zzz & echo
BG_after` lost its echo entirely). GNU expands the forked child's words
inside the child: the parent never observes the verdict, the diagnostic
prints once, and the launch line's remaining commands run.

Fix: the probe runs under an expansion_probe_active flag —
report_failglob stays silent while it is set — and the Err path
restores the expansion latches and the pre-probe exit code before
falling back to the wrapper, whose child reports exactly once.

Attribution note: this is a master regression from the #809 train
(28744c8 + CR rounds), reproduced on 5d51376 WITHOUT any #831 change;
the bisect is 0d87020/e2fcb78f PASS -> c0005ff (rebase onto
5d51376) FAIL. It surfaced on this branch only because the rebase
picked the regression up. The CR-round-2 collapse hypothesis does not
hold — the failing shape is a background `&`, not `( (… ) )`, and the
collapse flag is inert without a flat region.

Tests: tests/regression.rs issue_753 suite 17/17 (case_11 included);
failglob x collapse on/off battery (( (… ) ) collapsed, multi-command
uncollapsed, f() ( ) flat, `&` gate, plain ( )) byte-identical with WSL
GNU 5.3.0(1); issue720 17/17, issue797 8/8, goldens 74/74, audit
harness 45 cases (same 4 known findings); ERR 14-form battery
identical.
…sion scan (CI UTF-8 boundary hygiene)

parameter_expansion_assigns indexed the raw STRING with computed offsets
(&raw[cursor..]); the offsets were byte positions by construction (find
returns a byte offset, the walk advances over ASCII bytes only) but the
hygiene gate cannot prove it. Move all indexing onto the byte slice:
windows(2) over as_bytes() for the ${ marker (UTF-8 continuation bytes
are >= 0x80 so a two-byte ASCII window only matches at a boundary), and
starts_with on byte slices for the '=' / ':=' verdicts — no string
slicing left to justify.

Also close a multibyte hole the rewrite makes visible: a multibyte
character in the parameter-name position (${中文=…}) defeats the ASCII
identifier walk, so treat it conservatively and keep the wrapper (the
raw ':=' contains-check already covered the colon form; the multibyte
probe covers the colon-less one).

Multibyte regression (battery +3): ${中:=0.05} / ${中=0.05} keep the
wrapper (parent var not set), plain 中文 arguments ride the fast path —
byte-identical to base. Battery 44 probes; command_chaining 1517 passed
/ 9 pre-existing failures unchanged.
@caomengxuan666
caomengxuan666 merged commit 5ace807 into master Oct 18, 2026
6 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/809-bgwait-direct-spawn branch October 18, 2026 21:35
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