Skip to content

fix(executor): consume the arithmetic fatal flag at the triggering command boundary - #3365

Merged
caomengxuan666 merged 2 commits into
unixwin:masterfrom
Uarz:fix/issue-3287
Nov 11, 2026
Merged

caomengxuan666 merged 2 commits into
unixwin:masterfrom
Uarz:fix/issue-3287

Conversation

@Uarz

@Uarz Uarz commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #3287

What was fixed

After a fatal fast assignment, the arithmetic error flags leaked across commands: only the latch and non-fatal bits were consumed, so the fatal bit stayed in place and the next (( )) / let / for (( )) was skipped before evaluation, with all diagnostics silenced. GNU keeps no cross-command error state (expr.c:1525 evalerror only longjmps out of the current evaluation).

The fix treats the three flags as one error record that the triggering command consumes whole at its boundary: fast-assignment consumption sites clear the fatal (and non-fatal) bits, execute_arithmetic_command consumes all flags on nested fatal and returns Err(ExpansionFailure(1)) (DISCARD), and for (( )) headers call the existing abandon helper after a failed evaluation.

What was deleted

Nothing. No files, features, or tests were removed.

Verification (all run, per-item counts)

Owed

  1. gnu-extra.sh 8/8 acceptance probes are not in this workspace; not pinned.
  2. [[ ]] operand fatal leak ([[ $(( 1/0)) = x ]] then the next echo is still discarded) — the [[ ]] dispatch needs its own abort check; direction is the captain's call.
  3. Mixed-assignment-statement path and subshell-prefix path still ignore arithmetic_error (pre-existing gaps, not the leak itself).
  4. set -e + for (( i=1/0; ...)) pure-evaluation failure and set -e + (( )) bad-substitution: GNU behaviour unverified, out of scope.

…mmand boundary

The three arithmetic error flags are one error record and must be consumed whole by the command that triggered them. Only the latch and non-fatal bits were consumed, so the fatal bit leaked into the next (( )), let or for (( )) command, which was then skipped with all diagnostics silenced. GNU keeps no cross-command error state.

Refs unixwin#3287

Regression pin: tests/issue3287_fatal_fast_assignment_flag_leak.rs (9 tests; fail-first 4 failed on the unpatched tree, 9/9 pass after). Adjacent families (unixwin#3246, unixwin#2596, unixwin#1226, unixwin#439, unixwin#1541, unixwin#2125, unixwin#2126 and others) green.

Owed: [[ ]] operand fatal leak; mixed-assignment and subshell-prefix paths still ignore arithmetic_error; set -e + for (( i=1/0; ...)) and set -e + bad-substitution GNU behaviour unverified.
@caomengxuan666 caomengxuan666 self-assigned this Nov 11, 2026
@caomengxuan666 caomengxuan666 added bug Something isn't working gnu-baseline Tracked by the GNU Bash 5.3.0 true-baseline ledger P2-medium 中:次要缺陷或边缘路径,排期修复 area:expansion word splitting, quote removal, parameter/brace expansion labels Nov 11, 2026
@caomengxuan666

Copy link
Copy Markdown
Member

Thanks for the PR. This is queued for captain review — collaborator PRs are reviewed by the captain before merge, and #3287 stays open until that review lands. CI at intake: one red leg — Rust tests (macOS), the "Run Rust library tests" step failed; all other legs green. The captain's review will adjudicate whether it is change-related. No action needed unless the review asks for changes.

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 11, 2026 15:33
@caomengxuan666
caomengxuan666 merged commit 3ba430b into unixwin:master Nov 11, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:expansion word splitting, quote removal, parameter/brace expansion bug Something isn't working gnu-baseline Tracked by the GNU Bash 5.3.0 true-baseline ledger P2-medium 中:次要缺陷或边缘路径,排期修复

Projects

None yet

Development

Successfully merging this pull request may close these issues.

致命快赋值后算术致命/展开错误标志跨命令泄漏:后续 (( )) 求值被跳过、诊断全静默

2 participants