Skip to content

command_substitution_values.rs pipeline-filter arms are unreachable (dead) and carry the carrier defects #710

Closed

Description

@caomengxuan666

Summary

The pipeline-filter fast-path arms in
src/executor/command_substitution_values.rs (command_substitution_pipeline_filter,
line 5: sort, sed, tr, head, grep, wc, tail, uniq) are
unreachable for ordinary $( … | … ) substitutions on origin/master (and
were already unreachable at the installed e785c3c8). They are either dead code
to delete or a latent bug cache to wire up deliberately — and, if revived, they
carry the same carrier-decoding defects as the live pipeline arms.

Classification: inventory / dead code (with a latent payload-decoding
defect class).

Reachability proof

  • command_substitution_pipeline_filter has exactly one caller,
    command_substitution_pipeline_output
    (command_substitution_pipelines.rs:494).
  • That function requires a | (line 468) and is called only from
    timed_command_substitution_inner (line 585), reached only through
    timed_command_substitution_output (command_substitution.rs:802).
  • Line 802 executes only when command_substitution_body_is_trivial is true
    (line 792). That predicate (command_substitution.rs:2217) admits only
    [A-Za-z0-9 _-+=.,/:@%^] — it rejects |. So no body that can reach the
    filter can contain a pipeline stage.
  • git grep finds no other caller and no test exercising the arms.

Black-box confirmation — the arms' wc default is -l (one column), but the
live behaviour is the three-column default the real executor's pipeline arm
produces:

$ niu -c "x=\$(printf 'hello\n' | wc); printf '%s\n' \"\$x\""
      1       1       6

If the dormant arm ran it would print 1. Likewise $( … | sort/tail/uniq)
runs the external WinuxCmd binary (there is no pipeline arm for those), and
$( … | head/wc/grep/sed/tr) runs the live pipeline_exec.rs arm — which is
where all observable $() fast-path divergence actually lives.

Latent defects if revived

The dormant wc -c arm (command_substitution_values.rs:119) and tr arm
(line 45) have the same transport-carrier bugs as the live arms. The open
niubash#383 / rubash#695 already patches the wc -c arm even though it is
unreachable.

Ask

Decide per arm: delete it (the real executor already covers these pipelines), or
wire it back behind the triviality gate with a decode-at-entry fix. Either way,
add a reachability test so a future | shape regressing to "silently ignored
pipeline" (cf. #70/#76) is caught.

Found by the fast-path differential audit (#706).

Activity

  1. added
    enhancement
    area:fastpath
    area:carrier
    family:M1
    on Oct 17, 2026
  2. caomengxuan666 commented on Oct 18, 2026

    @caomengxuan666
    MemberAuthor

    Per-arm decision (PR #818)

    Decision: delete — no arm was revived; all eight were confirmed unreachable and removed.

    arm verdict
    sort dead-confirmed-removed
    sed dead-confirmed-removed
    tr dead-confirmed-removed
    head dead-confirmed-removed
    grep dead-confirmed-removed
    wc (incl. dormant wc -c carrier defect) dead-confirmed-removed
    tail dead-confirmed-removed
    uniq dead-confirmed-removed

    Verification summary:

    • Static: sole-caller chain re-derived; the issue's proof holds. One strengthening found: the chain not only needs | (rejected by command_substitution_body_is_trivial's byte whitelist) — it also lives inside the time-prefix shortcut, so even a gate admitting | would only consider $(time … | …) bodies.
    • Runtime: entry probes on all three chain links stayed silent across producer×filter batteries (incl. backtick, nested comsub, alias-injected |, heredoc shapes) on an unmodified build; a positive control admitting | in the gate fired all probes and reproduced the dormant one-column wc default. Control edits reverted.
    • Reachability test added (tests/issue710_comsub_pipeline_reachability.rs): pins the real-executor routing (wc default three-column, echo-led pipeline not swallowed, all 8 filters, time-prefixed pipeline, last-stage status), expectations byte-identical to WSL GNU Bash 5.3.0.
    • Full-suite ledger: failure sets identical to the origin/master baseline in both directions (43 pre-existing failures; 0 new, 0 fixed).

    Note: the dormant wc -c arm referenced as patched by open niubash#383 / rubash PR #695 is gone with the arm — #695's remaining scope is the live pipeline_exec.rs arms only.

  3. added a commit that references this issue on Oct 18, 2026
  4. added a commit that references this issue on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:carrierarea:fastpathenhancementfamily:M1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions