Skip to content

fix(executor): FUNCNEST overflow unwinds the command unit as DISCARD (Refs #2721) - #3692

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/2721-funcnest-discard
Nov 15, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/2721-funcnest-discard

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

【WIN-AGENT-FIX】

Problem

FUNCNEST=N overflow 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:). Pin issue2721_funcnest_discard: 2 red cells.

Root cause

GNU execute_cmd.c:5200-5206 execute_function: on 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 DISCARD arm keeps a nonzero last_command_exit_value and disposes the rest of the current command). Rubash's refusal returned Ok(()).

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; the run_unwind_protects analogue that lands funcnest back at 0) — is absorbed at an eval string boundary, ends a subshell frame, and settles as the unit's status at the driver.

Legs

  • Pin issue2721_funcnest_discard: 2 red on master → 2/2 green
  • GNU 5.3.20 script-file comparisons byte-identical (modulo the documented stdout/stderr interleave-order limitation): unit discard + FUNCNEST=0 re-run, counter reset across 3 fresh overflows, eval boundary absorption (EVAL-AFTER discarded, after-eval rc:1 runs)
  • Adjacent pins green: 1226, 1406, 1720, 2239, 2240, 2249, 2585 (1703 has a pre-existing master fd0-loop hang reproduced on this WSL tree — unrelated to the diff; 2658's 3 reds are the next lane item)
  • RUSTFLAGS="-D warnings" cargo build --locked clean

…(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.
@caomengxuan666
caomengxuan666 merged commit ca09d24 into master Nov 15, 2026
8 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant