Repository navigation
fix(executor): report E2BIG wording for an oversize command line (Refs unixwin/niubash#993 S4) - #3712
Merged
Merged
Conversation
…unixwin/niubash#993 S4) `spawn_error_diagnostic` classified the E2BIG/ENOMEM preemption (execute_cmd.c:6156 file_error -> sys_error -> strerror) by the unix errno values only. On Windows the same condition — an lpCommandLine past CreateProcess's 32767-char limit — surfaces as ERROR_FILENAME_EXCED_RANGE (206), which the generic strerror table renders "File name too long" (correct for path opens, ENAMETOOLONG's Win32 twin). Git Bash prints "Argument list too long", so a 200-KiB-argument spawn read `python.exe: File name too long` where GNU reports `Argument list too long`. Map raw os error 206 into the e2big class inside the spawn classification only — the table mapping itself stays 206 -> "File name too long" because a path-open failure with an overlong name is genuinely ENAMETOOLONG. The classification short-circuit and the rendered message both honor it: status stays EX_NOEXEC (126, execute_cmd.c:6143). Verification: issue repro `arg=$(printf 'a%.0s' {1..200000}); "$COMSPEC" x "$arg"` now prints `...cmd.exe: Argument list too long` rc=126 (was `File name too long`); new tests/niubash993_e2big_wording 3/3 (direct spawn wording, rc=126, exec-builtin wording); posix_errors unit tests 4/4; spawn regression files green except the two issue3198 deleted-cwd assertions which fail identically on clean master (path-separator expectation, unrelated). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
caomengxuan666
added a commit
that referenced
this pull request
Nov 16, 2026
…3734) * executor: port GNU async-stdin verdict to pipe-fed pipeline elements Refs #3605 exec13.sub's pipe-fed compound elements (`echo x | ( cat & wait )`, `| { cat & wait; }`, function elements) lost their lines: the async child spawned with /dev/null stdin because the element clone never inherited the "my stdin is a pipe" verdict. GNU anchors (bash-5.3 vendored tree): - execute_cmd.c:4570 — the forked element child does `stdin_redir |= (pipe_in != NO_PIPE)`; a pipe-connected element's async spawns read the pipe, not /dev/null. - execute_cmd.c:1733 — `execute_subshell_command` ASSIGNS `stdin_redir = (own fd-0 redirects) || (pipe_in != NO_PIPE)`; a nested `( )` clears an enclosing verdict, and the element's own `< file` replaces the pipe via do_redirections. - execute_cmd.c:1759-1764 — the :826 `stdin_redir = redirects` assign for shell control structures runs AFTER do_redirections consumed the element's fd-0 redirect, so it must not re-set the flag. - eval.c:181 — only reader_loop clears stdin_redir between commands; evalstring.c's parse_and_execute does not, so a clone replaying a pre-parsed element list must not clear either. - jobs.c:1743/nojobs.c child_setup — the async child consults the verdict when picking /dev/null vs inherited fd 0. Port: - `execute_pipeline_stage` gains a `stdin_is_pipe` parameter; the stage entry ORs it into `shell_state.stdin_redir` and the epilogue restores the caller's flag. Real-OS-pipe stage call sites (loop stages index > 0, streaming tail/mid) pass true; producer/stage-0 and the timed-read followup pass false. GNU's lastpipe quirk (prev = NO_PIPE before dispatching the last element) means the lastpipe path needs no marker. - New one-shot `element_pipe_stdin` Cell on ShellState: set on the compound-stage clone, consumed at the clone's own compound dispatch — the `( )` :1733-style assign (`own fd-0 redirects || marker`) and the :826-style assigns in `command_execute`/`execute_brace_group_pipeline`, both of which GNU skips for pipe-connected elements. - ast_exec's per-command reader-loop clear now only fires at subshell_depth == 0 (eval.c:181); a stage clone's body walk is not a reader loop. - `bind_command_fd0_input` drops the FUNCTION_STDIN(+OFFSET) mirror after binding a real fd-0 endpoint (file, procsub, net): GNU's do_redirections replaces fd 0 wholesale, so a stale pipe mirror must not shadow the bound file for `inherited_async_stdin`. Verification vs GNU bash 5.3.20 (script files, byte-identical stdout/stderr/rc): exec13.sub shapes x1/x1a/x2b/x3/x3a incl. GNU's empty x2/x2a, x3b + lastpipe forms, and a 13-form probe matrix (pipe-fed `( )`/`{ }`/if/while/for/case/select/coproc elements, element-own-`< file` override, nested-clear assign semantics, stage-scoped flag death). niubash gate slice run-execscript: the x1..x3b family now matches exec.right; remaining diffs are the already-tracked E2BIG/#3712, exec -a prolog, coproc and job-control noise. tests/issue3605_pipeline_async_stdin.rs pins the four shapes (4 tests). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(tests): quote fixture path in pipe-stdin pins for Windows (Refs #3605) --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Summary
spawn_error_diagnosticmatched the E2BIG/ENOMEM preemption (execute_cmd.c:6156file_error->sys_error-> strerror) by unix errno values only. On Windows an lpCommandLine past CreateProcess's 32767-char limit surfaces asERROR_FILENAME_EXCED_RANGE(206), which the generic strerror table rendersFile name too long— correct for path opens (ENAMETOOLONG's Win32 twin), wrong here.posix_errorstable mapping stays untouched. Both the sampling short-circuit and the rendered message honor it; status staysEX_NOEXEC(126,execute_cmd.c:6143).GNU anchors
execute_cmd.c:6143status switch (ENOENT->127 else 126)execute_cmd.c:6156-6159i == E2BIG || i == ENOMEM->file_error (command)Verification
$COMSPEC):...cmd.exe: Argument list too longrc=126 (wasFile name too long).tests/niubash993_e2big_wording.rs: 3/3 (spawn wording, rc=126,execbuiltin wording — same classification path atbuiltins/exec.rs:794).posix_errorsunit tests 4/4; spawn regression files (issue3091/3420/3198) green except two issue3198 deleted-cwd assertions that fail identically on clean master (path-separator expectation, unrelated).Generated with Devin