Skip to content

fix(#282) [P1-high]: eval EOF-shape probe is comment-aware - restores the modernish fatal.sh battery receipt (166-probe ledger) - #572

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/282-eval-comment-blind-probe
Oct 12, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/282-eval-comment-blind-probe

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Closes #282. P1-high: modernish is a published ecosystem receipt (166-probe ledger, rubash#477) - the fatal.sh battery abort killed the whole receipt on master (every capability probe rc=128, init cannot start).

Repro

  • LF modernish @63bdae02 clone + harvest goodsh patch; echo 'exit 0' | rubash bin/modernish -> modernish: Fatal shell bug(s) detected, rc=128; MSH_FTL_DEBUG=1 traced 4 lines, dying at the FTL_CSCMTQUOT probe eval ': || $( : # "\n)' (fatal.sh:514-518) with "unexpected EOF while looking for matching `)'". GNU Bash 5.3.0 (WSL oracle): silent rc=0.

Bisect

git bisect run with rubash.exe direct (probe rc classifier, good=7a2bfdf4, bad=41de8319): first bad commit 206dc04 (rubash#318) - it added lexer::unclosed_comsub_eof_shape, a comment-blind scanner. Its parent 8064c2f is good.

Root cause

The eval EOF-shape pre-probe (execute_eval, trap_exec.rs) tracked quotes/escapes/parens but had no # comment branch. The in-comment " of the FTL_CSCMTQUOT string flipped its double-quote state, swallowed the newline AND the closing ), the comsub stack entry never popped, and the probe fabricated ComsubEof - a fatal eval abort for input GNU parses cleanly.

GNU owner: parse.y:3630-3643 (read_token -> parse_comment): a word-initial # comments out the rest of the physical line; comment text - quotes and parens included - is discarded (word-initial test :3937-3940). Same rules wt12 already landed for the completeness scanners (CommentAwareScan, 7a2bfdf); this ports them onto the eval probe.

Fix

  • token_boundary state in unclosed_comsub_eof_shape (comment branch at token boundaries; terminating newline left for the line counter; backslash-escaped chars are word text; boundary mirrors BraceScan's operator/whitespace idiom).
  • token_after_paren: word-initial # after the shifted function-definition paren comments out the line, so the yacc error names newline.
  • The None outcome is unchanged: x=( and $(( still defer to the generic close-char scan (oracle-checked, incl. $((1 # 2)) rc=1 and same-line $(echo a # b) plain-EOF).

Tests

modernish battery rerun (receipt)

  • Plain init (echo 'exit 0' | rubash bin/modernish, LF 63bdae02 + harvest goodsh patch + MSH_SHELL=/usr/bin/bash): silent rc=0, byte-identical to GNU; with MSH_FTL_DEBUG the battery traces 157 lines through its success path (trap 'echo $PPID' 0 -> echo $PPID).
  • 2/2 ecosuite fixtures (tests/fixtures/ecosuite/modernish/) byte+rc identical.
  • 164-cap rc-vector sweep (fresh child shell per cap, [bug] modernish cap .t suite: 5/164 capability probes diverge from GNU 5.3.0 (BUG_CSUBBTQUOT, BUG_PSUBSQUOT, BUG_SCLOSEDFD, QRK_BCDANGER, QRK_EMPTPPWRD) #258 method + init): 139/164 agree with GNU. The 25 divergences (QRK_LOCALINH/LOCALSET*, QRK_BCDANGER, QRK_EMPTPPFLD, TESTERE, WRN_*, BUG_TRAPZERR, ...) are pre-existing capability-semantic differences (local inheritance/quirk family), unreachable from this lexer change; on pre-fix master they all read rc=128 because init itself was dead. Re-claiming the full 166/166 README number needs its own capability-parity pass and is out of this PR's scope.

License red lines: no license files touched, no new dependencies, no vendored-source changes.

…omments no longer fabricate unclosed comsub (FTL_CSCMTQUOT)

modernish bin/modernish init aborted in the fatal.sh battery with
MSH_FTL_DEBUG silent: the battery's FTL_CSCMTQUOT probe
(lib/modernish/adj/fatal.sh:514-518, the eval of ': || $( : # "\n)')
died on a fabricated "unexpected EOF while looking for matching ')'"
before any traceable statement. Receipt regression: the 166-probe
modernish ledger (rubash#477) is dead on master - every capability
probe returns 128 because init cannot even start.

Bisect (rubash.exe direct, probe rc as classifier, good=7a2bfdf4,
bad=41de8319): first bad commit 206dc04 (rubash#318), which introduced
lexer::unclosed_comsub_eof_shape. The probe's scanner tracked quotes,
escapes and parens but had NO comment branch: the in-comment double
quote of the FTL_CSCMTQUOT string flipped its double-quote state,
swallowed the newline and the closing ")", and the comsub stack entry
never popped - ComsubEof - fabricated eval abort (execute_eval
pre-probe in trap_exec.rs).

GNU owner: parse.y:3630-3643 read_token -> parse_comment - a
word-initial "#" comments out the rest of the physical line and comment
text is discarded (quotes and parens are data); word-initial test at
parse.y:3937-3940. Mirrors the CommentAwareScan boundary rules wt12
landed for the completeness scanners (7a2bfdf) onto the eval EOF
probe.

Fix: token_boundary state in unclosed_comsub_eof_shape (comment branch
at token boundaries, newline left for the line counter, backslash
escapes are word text), plus token_after_paren treating a word-initial
"#" after the shifted function-definition paren as a comment (next
token = newline). The None outcome is unchanged, so the "x=("
compound-assignment and "$(( " arithmetic families still defer to the
generic close-char scan.

Tests: tests/issue282_eval_probe_comment_regressions.rs - 7 script-file
probes pinned byte-for-byte vs WSL GNU Bash 5.3.0, RED 5/7 on pre-fix
master, GREEN 7/7 post-fix. Full cargo test --no-fail-fast failure set
vs fresh master: identical by name, bidirectional (67 pre-existing
environment-bound failures on both sides, none eval- or lexer-related).
cargo fmt clean.

Verified: modernish @63bdae02 LF clone + harvest goodsh patch - plain
init silent rc=0 at GNU parity, with MSH_FTL_DEBUG tracing 157 lines
through the battery's success path (was: rc=128, trace silent).
@caomengxuan666

Copy link
Copy Markdown
Member Author

Independent verification (regression root-cause pass, clean clone D:/repo/research/282-verify, corpus D:/repo/research/282-verify-modernish @63bdae0 LF + harvest goodsh patch):

Repro (RED) confirmed on fresh master d116874 — echo 'exit 0' | rubash bin/modernish → Fatal shell bug(s) detected, rc=128; with MSH_FTL_DEBUG the trace dies at the FTL_CSCMTQUOT probe eval $': || $( : # "\n)' with "unexpected EOF while looking for matching `)'". WSL GNU 5.3.0: silent rc=0 on the same string.

Bisect conclusion reproduced: parent 8064c2f probe rc=0 + init rc=0 (GOOD); first bad 206dc04 — probe fabricates EOF, init rc=128 (BAD). git log -S unclosed_comsub_eof_shape shows only 206dc04 + its #333 follow-up touch the scanner; the 206dc04 version has no comment branch. Matches the PR's bisect (good=7a2bfdf4, bad=41de8319 → 206dc04).

GREEN confirmed on this branch (054c654): plain init silent rc=0, byte-identical to GNU; 2/2 ecosuite fixtures byte+rc identical; new regression tests 7/7; cargo fmt --check clean.

Full cargo test --no-fail-fast failure-set identity vs fresh master (d116874): 44 vs 43 failing tests by name; the single only-in-PR entry is executor::path::tests::virtual_system_root_operand_resolution_keeps_option_b_and_legacy_verbatim — its fix landed post-base on master (ea36410/c20b0b8a, #574, not in this branch's base 1184c96), so it is a stale-base artifact, not a PR regression. No eval/lexer/modernish-adjacent failures on either side. Zero only-in-master entries.

Receipt rerun note: the full 166/166 capability-parity re-claim stays out of scope here as written in the description (current sweep: init-level parity + fixtures). One follow-up blocker found during verification and filed separately as #575 — $(exec cat) loses inherited stdin (exec.rs spawn paths never plumb child stdin; Command::output() defaults it to null), which breaks modernish's stdin-script mode (echo script | bin/modernish runs only the preload line). Does not affect this PR's claims: init-level receipt used single-line stdin and -c/file modes are unaffected.

@caomengxuan666
caomengxuan666 merged commit ff3a711 into master Oct 12, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/282-eval-comment-blind-probe branch October 13, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1-high 高:核心语义或高频路径受损,影响日常使用/发布

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] modernish bin/modernish init aborts in fatal.sh battery after #256/#257 (MSH_FTL_DEBUG produces no output, uncited)

1 participant