Repository navigation
fix(executor): contain the assignment DISCARD jump at the eval boundary (#637) - #657
Merged
Merged
Conversation
…ry (#637) eval 'a=(p); a[-2]=q; echo IN'; echo AFTER ended the whole script with status 1. GNU catches DISCARD at the eval boundary (evalstring.c:365,422-442): eval returns failure and the caller continues. Rubash absorbed ExpansionFailure there but let the evalerror_pending abort escape. A distinct evalerror_subscript_pending cell marks bad-subscript aborts (armed at the element-write sites + compound tail); the eval boundary absorbs exactly this class on Ok, leaving the exit status to the last command run (GNU parse_and_execute loop: a later line that ran fine yields eval rc 0). Arithmetic and nounset failures never arm it and keep escaping; a real Err propagates untouched (dropping a leaked mark). The eval'd top list runs at a recorded depth so nested aborts fall through to line-skip logic instead of unwinding silently; deeper function/loop bodies keep unwinding. Consumed at abandon (outside eval strings) and cleared at every pending-clearing boundary. Verification: new 20-case GNU differential 9/20 -> 20/20; new tests/issue637_eval_discard.rs (9 tests); all other batteries unchanged (nounset 25/25, atstar 14/15 with #635 case, indexed 49/50 with #651, assoc 50/50); focused suites green; full serial failure-set gate vs ea9c18e identical targets (NEW=0/DISAPPEARED=0; 3/1 part_080 coproc flake passing in isolation); niubash A/B identical apart from the known load-flaky timing test (passes in isolation on the failing leg).
This was referenced Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(executor): contain the assignment DISCARD jump at the eval boundary (#637)
What
eval 'a=(p); a[-2]=q; echo IN'; echo AFTERended the whole script withstatus 1. GNU catches DISCARD at the eval boundary
(
evalstring.c:365,422-442) — eval returns failure and the callercontinues. Rubash absorbed
ExpansionFailurethere but let theevalerror_pendingabort escape.Fix
evalerror_subscript_pendingclass marker, armed alongside theabort at the bad-subscript sites (plain
a[-2]=q/a[]=v/[@]/unresolvable-negative in element assignment, compound-negative tail).
Arithmetic and nounset failures never arm it, so they keep escaping.
execute_eval_sourceabsorbs exactly this class onOk: clearspending/line/marker, returns
Ok(eval fails, caller continues). Areal
Errpropagates untouched (and drops a leaked mark so an outereval cannot mistake it for its own string).
(
eval_list_depth: Cell<Option<usize>>, save/restored per evalnesting): nested aborts unwind silently everywhere EXCEPT that frame,
where GNU's parse_and_execute loops per line — a later line still runs
and eval returns its status. Function/loop bodies inside eval run
deeper and keep unwinding.
pending-clearing boundary (subshell/comsub/external/function resets),
same discipline as the nounset cell — except inside an eval string,
whose boundary owns absorption.
last status (a later line that ran fine yields eval rc 0).
Verification
Covers contained plain/empty/compound/nested/fn/eval-rc/
||/multilineshapes plus guards (arith escape, eval-in-subshell, top-level controls).
tests/issue637_eval_discard.rs(9 tests).declare -a a=( [-2]=q ) / local -a a=( [-2]=q ) still drop an out-of-range negative subscript (builtin route of #631) #635-reserved case, indexed 49/50 with unset 'a[@]' leaves stale typed cell: ${#a[@]} disagrees with the mirror #651, assoc 50/50).
compound-quote, 536-class); full serial failure-set gate vs
ea9c18e:target sets identical (NEW=0/DISAPPEARED=0); test-level 3 NEW / 1
DISAPPEARED all in the known-nondeterministic
part_080coproc family(all four pass in isolation on branch).
Out of scope
subscript+arithmetic in one eval string follow evaluation order
(verified against GNU in the battery).
eval-boundary primitive (see declare -a a=( [-2]=q ) / local -a a=( [-2]=q ) still drop an out-of-range negative subscript (builtin route of #631) #635 recon).
GNU owners:
evalstring.c:365,422-442(DISCARD catch),subst.c:11169-11176 bash_variable_assignment_error,arrayfunc.c:1388-1390(arith escape, deliberately untouched).