Repository navigation
fix(wave3): P3 batch — xtrace case word, redirect message fidelity, caller stack limit, trap -p ERR display, extdebug DEBUG-skip sites, syntax-error echo, job signal notice (#517 #518 #519 #520 #521 #522 #550) - #569
Merged
Conversation
…ntax-echo/job-notice (#517 #518 #519 #520 #521 #522 #550) #517 xtrace case head (src/executor/compound_exec.rs): trace the RAW word (word_metadata.raw, the WORD_DESC-text equivalent) instead of the quote-stripped lexer value, decoding at the output boundary. GNU xtrace_print_case_command_head (print_cmd.c:742-749) prints case_command->word->word, which still carries the source quotes. The old path leaked the PARAM_NAME_END_MARKER boundary byte (0x13) into the trace: `+ case $x^S in` -> `+ case "$x" in`. #518 redirection message fidelity: - expand_redirect_target strips the fully-quoted-word role marker (STORAGE_WORD_PREFIX) from the expanded operand; the marker corrupted dup-word classification and leaked 0x1d into diagnostics. `r <&"${X[0]}"` (X set-empty) is one anchored empty field, not ambiguous; all_digits("") vacuous + valid_number("") fail -> dest -1 -> EBADF with the raw word: `"${X[0]}": Bad file descriptor` (redir.c:784-843 + redirection_error redir.c:149-176). - the function-invocation fast path (command_prepare.rs execute_function_command_invocation) now runs the same reject_invalid_redirects gate as execute_materialized_command — GNU applies one do_redirections list for every simple command kind (redir.c:246). - append-open errors map through posix_errors::path_error at every bare open site (redirection.rs open_command_output_target, builtin_redirects.rs, external_redirects.rs open_external_combined_ target): redirection_error (redir.c:149-176) carries the target word, so `cmd >> word &` reports `word: No such file or directory` on every attempt instead of a wordless strerror line. #519 caller (src/executor/arrays/executor.rs indexed_array_stack): the synthetic FUNCNAME bottom frame "main" is pushed ONLY when has_script_main_frame() (GNU shell.c:1636-1648 open_shell_script pushes funcname_a "main" for script files; bash -s/-c never enter it), matching the dynamic_stack_array_values view. caller.def:108-121 fails with EXECUTION_SUCCESS=1 and no output when FUNCNAME[expr+1] is absent, so `caller 1`/`caller 2` at g->f depth are empty rc=1 — no fabricated `10 main <path>` line. #520 trap -p ERR in functions (src/builtins/trap.rs, function_calls.rs): execute_cmd.c:5279-5286 removes the inherited ERR trap for the function body unless error_trace_mode (set -E), with uw_maybe_set_error_trap restoring it at exit. Rubash now saves/clears/restores the ERR action at the function boundary, so `trap -p ERR` shows an empty context while the firing behavior (already GNU-correct) is unchanged. #521 extdebug DEBUG-skip (trap_exec.rs run_debug_trap + fire sites): the skip rule is now `extdebug && trap status != 0` — GNU's fire-site contract (execute_cmd.c:3057/3191/3532/3672/3924/4157/4510/5391) — replacing the old status==2-without-extdebug rule, and $? is preserved across a DEBUG firing (probe: `trap 'false' DEBUG; true; echo $?` -> 0). The decision is now HONORED at: case head (3672: skip whole case, status SUCCESS), select head (3532), for header (3057: continue — skip the iteration, next word runs; final-iteration skip leaves the trap's status), arith-for init/test/update (3191-3199: expression evaluates as 0 with ok=1), pipeline stage (4510 in the element child: empty output, stage status = trap status), function entry (5391: skip body and RETURN trap, call status SUCCESS). Statuses after skips follow the probes: skipped simple/case/select/function leave $? = 0 (m1/k9/m2); the pipeline of two skipped stages is 1 (i521d). #522 arith-for syntax error echo (src/parser/parse_loop.rs): the error node carries its line (`line N:` prefix via parser_diagnostic_prefix_for_line) and the between-parens text is rebuilt VERBATIM from token leading_ws+raw (`((i=0; i<3))`, not the normalized `(( i=0; i<3 ))`) — GNU error.c:300-316 parser_error + parse.y:6813-6826 print_offending_line echo the source as read. #550 cell 2, job signal notices (src/builtins/kill.rs signal_death_description): the Windows fallback maps the invariant signal numbers to the glibc strsignal wording the oracle prints (SIGKILL -> `Killed`, jobs.c:1955 j_strsignal), keeping j_strsignal's `Signal %d` only beyond the table. Cell 1 (`~root:x`) is NOT changed: the lookup logic already matches GNU (unresolvable users stay literal on both); `/root` comes from Linux's user database, which Windows does not have — platform discount per the issue's own recommendation. Tests: tests/issue5{17,18,19,20,21,22}_*.rs, tests/issue550_job_notice_and_tilde_regressions.rs (36 cases, all byte-verified against WSL GNU Bash 5.3.0 script-file/stdin probes). Full cargo test --no-fail-fast: the failing set is IDENTICAL to fresh origin/master (db3218a) by test name in both directions (44 failed names, 8 failing targets on each side; the master reds are pre-existing and untouched).
…Rejection protocol #561 reshaped reject_invalid_redirects to classify rejections (RedirectRejection::Command / FatalNounset). The function-invocation fast path follows the execute_materialized_command consumer shape: FatalNounset raises the same finish_heredoc_expansion_error the materialized path raises (rubash#535's main-shell/child split), Command skips the call with the tempenv restore and process-substitution finishes still applied.
caomengxuan666
force-pushed
the
fix/wave3-p3-batch
branch
from
October 12, 2026 06:25
262d645 to
f8d7af9
Compare
This was referenced Oct 12, 2026
2 tasks done
caomengxuan666
added a commit
that referenced
this pull request
Oct 13, 2026
M0 design draft for rubash#497, written to be startable as-is: - Scope pinned: one debuggee topology (script in the host process, pdb/debugpy model), DAP minimal surface over stdio (launch / same-process-spawn-only attach / setBreakpoints by file:line / stackTrace / scopes / variables / evaluate / pause-continue-step). - Stop substrate anchored to the existing run_debug_trap seam family — all 11 dispatch points enumerated with file:line at 7f18b44 (trap_exec.rs:716 funnel; ast_exec.rs:541; compound_exec.rs:334/982/ 1135/1170/1232/2305; function_calls.rs:531; loop_select.rs:117; pipeline_exec.rs:672; select_exec.rs:64) plus the function-return patch point (trap_exec.rs:781) for the extdebug force-return hole. - Breakpoint injection: recommends executor PC hooks (the seam family is the PC, GNU DEBUG-trap distribution is the stop-site set, no second admission list per #117) with the parse-tree line walk (parser/nodes.rs:1252 CommandNode.line) used only for verified:false resolution at setBreakpoints time; reasons stated. - Frame/scope/evaluate reuses landed structures: funcname_stack / bash_source_stack / bash_lineno_view (dynamic_arrays.rs:683/687/409), main-frame rule (#519, dynamic_arrays.rs:389-395), ERR entry-state parity pattern (#520), function_definition_locations (function_calls.rs:495-511); extdebug surface (#569 sites, trap_exec.rs:773-775) and #571 bind -v registry as the CLI's readline foundation. - Non-goals, acceptance (golden DAP transcripts + bashdb oracle), scale estimate (~3,000-4,500 LOC, no new crates), M1 outlook, and three owner decision points (frontend order; --debug flag semantics; M0 stop-site granularity).
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
P3 batch (Wave3): seven issues, each root-caused against the vendored GNU bash 5.3.0 C source (
third_party/bash@ b4608166) and byte-verified against WSL GNU Bash 5.3.0 (script-file / stdin-harness probes, 2026-10-12).PARAM_NAME_END_MARKERboundary byte leaked raw (+ case $x^S in)word_metadata.raw), decoded at the output boundaryxtrace_print_case_command_headprint_cmd.c:742-749 (printsword->wordwith source quotes)STORAGE_WORD_PREFIXrole marker -> wrong class + marker leak; the function-invocation fast path bypassed the redirect gate; (b) append-open errors propagated bare OS errors, so the renderer dropped the wordexpand_redirect_target; runreject_invalid_redirectson the function path;path_error-map every append openindexed_array_stack("FUNCNAME")padded a syntheticmainframe unconditionally ->caller 2at g→f depth invented10 main <path>rc=0has_script_main_frame()(same as thedynamic_stack_array_valuesview)open_shell_scriptpushes FUNCNAME "main" for script files only; caller.def:108-121 absent element ->EXECUTION_FAILUREtrap -p ERRinside a function showed the inherited trap; the display disagreed with the (already correct) non-inherited firingset -E, restore at exitrestore_default_signal (ERROR_TRAP)+ uw_maybe_set_error_trapstatus==2with no extdebug gateextdebug && status != 0; decision honored at case/select head, for header, arith-for init/test/update, pipeline stage, function entry;$?preserved across a firing$?preservation probe-verified (trap 'false' DEBUG; true; echo $?-> 0)(( i=0; i<3 ))with noline N:leading_ws+rawSignal 9; cell 1 (~root:x)Killed); cell 1 intentionally unchanged — the lookup logic already matches GNU (unresolvable users stay literal on both);/rootcomes from Linux's user DB which Windows lacks — platform discount per the issue's own recommendationVerification
tests/issue5{17,18,19,20,21,22}_*.rs,tests/issue550_job_notice_and_tilde_regressions.rs— 36 cases, all green, expectations byte-verified against WSL GNU Bash 5.3.0.cargo test --no-fail-fast: the failing set is identical to freshorigin/master(db3218a) by test name in both directions — 44 failed names / 8 failing targets on each side (--lib, cli_tests, executor_tests, issue298_299, issue377, issue382, parameter_transform_tests, regression — all pre-existing master reds, untouched). wave3 runs 173 green targets vs master's 166: exactly the 7 new files.cargo fmt --checkclean; no debug instrumentation left.Out of scope / notes
return Nhas exotic GNU-specific behavior not replicated here.for ((i=0;i<3;))(empty update section): GNU accepts it (infinite loop); rubash reports;' unexpected— pre-existing divergence, untouched by this PR.Rebase note (2026-10-12, post-#561/#562/#563)
Rebased onto
origin/master2183fc9 (the auto-merge needed one semantic adaptation):reject_invalid_redirectsnow returnsOption<RedirectRejection>(P1 Wave1: six semantic fixes (#524 #525 #529 #532 #535 #536) — trap exit unwind, pipeline redirect failures, indirect declared-unset, runtime bad substitution, redirect-word nounset, malformed subscripts #561). The function-invocation gate follows theexecute_materialized_commandconsumer shape:FatalNounsetraisesfinish_heredoc_expansion_error(rubash#535),Commandskips the call with tempenv restore + process-substitution finishes (f8d7af9).run_debug_trap(take→stamp→execute→put back untouched; the skip decision reads the post-execute status only).maybe_run_error_trapfire-time gate: during the body the table entry is gone, so exactly one adjudication point can fire — the caller-level check after the call fails. No double fire.Post-rebase verification (all green): full probes re-run byte-identical to WSL GNU 5.3.0; 7 new suites (36 cases) green; full
cargo test --no-fail-fastfailing set identical to freshorigin/master2183fc9 by test name in both directions (55 failed names / 8 failing targets on each side — the same pre-existing master reds);cargo fmt --checkclean.