Skip to content

fix(2881): add the LITERAL_CHAR_ESCAPE arm to the boundary decoder (Refs #2881) - #2911

Merged
caomengxuan666 merged 6 commits into
masterfrom
fix/2881-e1-boundary-decode
Nov 6, 2026
Merged

caomengxuan666 merged 6 commits into
masterfrom
fix/2881-e1-boundary-decode

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Refs #2881 — lane delivery, CAPTAIN-VERIFIED 2026-11-06 (see verification section).

Fixes #2881

What

decode_raw_byte_markers_to_byte_chars (src/executor/substitution_metadata.rs) — the decoder used at the external boundary — handled only U+E000 raw-byte pairs and passed LITERAL_CHAR_ESCAPE (U+E400) pairs through untouched, so a value containing a typed registry-zone char (e.g. v=$'\uE314') reached real child processes as the U+E400 + char escape pair. Its sibling decode_raw_byte_markers has the E400 arm. GNU hands execve the raw word bytes (execute_cmd.c shell_execve, cited in the decoder's own doc comment), so the child must receive the raw char — byte-verified against GNU bash 5.3.20 by the #2879 sweep (battery cells c08/c09).

Fix: add the missing LITERAL_CHAR_ESCAPE arm to decode_raw_byte_markers_to_byte_chars, mirroring the sibling (E400 + c → c verbatim; trailing E400 stays). The mechanism (the decoder's unit grammar) is fixed, not the call sites.

Caller census (codegraph-first, rg cross-check)

callers decode_raw_byte_markers_to_byte_chars on the master index (e8f1bb0) returns exactly 3, all external boundaries; rg over src/ agrees (definition + 3 call sites):

  • external_command_for_named_program_with_exec_name — src/executor/path.rs (child argv)
  • apply_env_command_environment — src/executor/external_inner.rs (env builtin environment)
  • child_env_value — src/executor/readonly_functions.rs (child env)

Pins

  • Unit (in src/executor/substitution_metadata.rs tests): issue2881_raw_byte_decoders_agree_on_registry_inputs — one unit walk renders the expected decode in both output domains for every registry codepoint (MARKERS table), every raw-byte payload U+E001..=U+E100, and the edge shapes (trailing E400/E000, E000+E000, E400+E400, mixed); issue2881_byte_char_decoder_folds_typed_registry_char — the c08/c09 seed at decoder level.
  • Integration (tests/issue2881_boundary_decode_regressions.rs, unix): c08 child-env shape, c09 child-argv shape, and the env-builtin shape against real /usr/bin/env / /usr/bin/printf children, with raw-C0 controls. The third call site (child_env_value) shares the same decoder and is covered by the unit parity pin.

Fail-first (lane record, logs in the lane workdir): against the unfixed decoder the unit pins ran 0 passed / 2 failed and the integration stem 0 passed / 3 failed (child env carried the raw U+E400 pair; child argv bytes were the pair's UTF-8).

Captain verification (2026-11-06, head cf90157)

  • --lib issue2881: 2 passed / 0 failed.
  • --test issue2881_boundary_decode_regressions: 3 passed / 0 failed.
  • Full lib suite: 1141 passed / 0 failed / 3 ignored (master caliber 1139 + the 2 new unit tests).
  • Neighbourhood on the lane record: marker_leak_golden 9/9, issue824 9/9, carrier_byte_class 16/16, issue1634 6/6, issue735 5/5. The issue2259 integration stem shows 5 passed / 1 failed in this environment — the identical failing test on the master-decoder baseline, i.e. pre-existing here, not caused by this change.
  • CI on cf90157: all checks pass, including the UTF-8 boundary hygiene step (see the process note).

Process note (captain's own error, recorded)

The first CI generation failed the "Check UTF-8 boundary hygiene" step on a byte as char widening in the parity pin's TEST helper (production code was clean). The captain's hygiene fix commit (653e55f) was made while the lane's baseline sweep had the same file checked out at the master version, so the pushed head silently lost the fix + unit tests. Commit cf90157 reverts that commit (restoring the fix byte-for-byte) and re-applies the hygiene spelling (char::from(byte), with a comment recording that the widening is the decoder's documented byte-char contract). The final head's diff vs master is exactly the decoder arm + doc + pins (+255/−0, 2 files), read in full by the captain before pushing.

本 PR 删除了什么

Nothing deleted. The change is one added match arm in the boundary decoder plus tests.

Net lines

+255 / −0 across 2 files (src/executor/substitution_metadata.rs +119, tests/issue2881_boundary_decode_regressions.rs +136).

Fail-first pins for #2881 (PUA/carrier sweep F1, fix item E1).
decode_raw_byte_markers_to_byte_chars — the decoder at the three
external boundaries — has no LITERAL_CHAR_ESCAPE (U+E400) arm, so
typed registry-zone chars reach real children as the escape pair
where GNU bash hands over the raw bytes (execute_cmd.c shell_execve
contract; sweep battery c08/c09 vs GNU 5.3.20).

- unit: parity test asserting both raw-byte decoders agree on all
  registry inputs, plus the c08/c09 seed fold at decoder level
- integration (tests/issue2881_boundary_decode_regressions.rs):
  c08 child-env, c09 child-argv and env-builtin shapes against real
  /usr/bin/env and /usr/bin/printf children

UNVERIFIED-BY-CAPTAIN
decode_raw_byte_markers_to_byte_chars — the decoder at the three
external boundaries (child argv, child env, env-builtin env) — had
no LITERAL_CHAR_ESCAPE (U+E400) arm, so a typed registry-zone char
reached real child processes as the U+E400 + char escape pair.
GNU hands execve the raw word bytes (execute_cmd.c:6126
shell_execve), so the child must receive the raw char; the #2879
sweep byte-verified the leak against GNU bash 5.3.20 (cells
c08/c09).

Add the missing arm, mirroring the sibling decode_raw_byte_markers:
E400 + c emits c verbatim; a trailing E400 stays E400. The fix is
in the decoder's unit grammar, not at the call sites. Within the
raw-byte decoder family this was the only missing arm
(shell_text_to_raw_bytes, shell_text_prefix_for_raw_len and
decode_raw_byte_markers all carry it).

Fail-first evidence: the pins from the previous commits run red on
the unfixed decoder (unit left = "\u{e400}\u{e314}"; child argv
left = the pair bytes) and are re-run green with this commit.

UNVERIFIED-BY-CAPTAIN
The parity pin's expected-decode helper built its byte-char domain
text with `byte as char`, which trips the UTF-8 boundary hygiene gate
(scripts/check-utf8-boundary-hygiene.sh) — CI's Rust tests job failed
at that step before running any test. The widening itself is the
decoder's documented contract (byte value == code point); char::from
spells the same mapping explicitly and keeps the guard meaningful.

Refs #2881
…ptain)

653e55f landed while the lane's baseline sweep had
src/executor/substitution_metadata.rs checked out at the master
version, so it silently reverted the fix arm, its doc comment, and
both unit tests — only the integration stem survived. This commit
restores all of them byte-for-byte from a277c03, with one intended
delta: the parity pin's expected-decode helper now spells the
byte-char widening as char::from(byte), which is the same mapping
(byte value == code point, the decoder's documented contract) in the
explicit form that does not trip scripts/check-utf8-boundary-
hygiene.sh — the gate that failed CI's Rust tests job at the hygiene
step before any test ran.

Refs #2881
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 6, 2026 14:59
@caomengxuan666
caomengxuan666 merged commit e5fe55e into master Nov 6, 2026
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.

External boundary leaks the E400 escape pair into child env/argv (decode_raw_byte_markers_to_byte_chars lacks the LITERAL_CHAR_ESCAPE arm)

1 participant