Repository navigation
fix(executor): FUNCNEST overflow unwinds the command unit as DISCARD (Refs #2721) - #3692
Merged
Merged
Conversation
…(Refs #2721) GNU execute_cmd.c:5200-5206 execute_function: on nesting overflow bash runs the unwind protects, resets funcnest = 0, and jump_to_top_level(DISCARD) — the rest of the current command unit is discarded while the reader continues with the next unit (eval.c:111 keeps a nonzero last_command_exit_value and disposes the rest of the current command). The refusal previously printed the diagnostic, set status 1, and returned Ok, so the surrounding list kept running. Return the DISCARD spelling (ExpansionFailure) from the refusal site: it propagates through the surviving function frames — whose epilogues run the frame unwind (locals, positional params, function_depth-=1, the run_unwind_protects analogue that lands funcnest back at 0) — is absorbed at an eval string boundary, and settles as the unit's status at the driver so the reader proceeds.
This was referenced Nov 15, 2026
[B3-F03] FUNCNEST overflow does not abort the enclosing command list (no DISCARD-class unwind)
#2721
Closed
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.
【WIN-AGENT-FIX】
Problem
FUNCNEST=Noverflow printed the diagnostic and set status 1 but returned normally, so the rest of the enclosing command unit kept executing (f; echo rc:$?printed rc:). Pinissue2721_funcnest_discard: 2 red cells.Root cause
GNU
execute_cmd.c:5200-5206 execute_function: on overflow bash runs the unwind protects, resetsfuncnest = 0, andjump_to_top_level(DISCARD)— the rest of the current command unit is discarded while the reader continues with the next unit (eval.c:111DISCARD arm keeps a nonzerolast_command_exit_valueand disposes the rest of the current command). Rubash's refusal returnedOk(()).Fix
Return the DISCARD spelling
Err(ExecuteError::ExpansionFailure(1))from the refusal. It propagates through the surviving frames — each epilogue runs the frame unwind (locals, positional params,function_depth -= 1; therun_unwind_protectsanalogue that lands funcnest back at 0) — is absorbed at anevalstring boundary, ends a subshell frame, and settles as the unit's status at the driver.Legs
issue2721_funcnest_discard: 2 red on master → 2/2 greenFUNCNEST=0re-run, counter reset across 3 fresh overflows,evalboundary absorption (EVAL-AFTERdiscarded,after-eval rc:1runs)RUSTFLAGS="-D warnings" cargo build --lockedclean