Skip to content

regression(ba69f0d9): exec-copied fds (exec 3>&2) no longer honored by external command redirects (>&3 lands on wrong stream) #370

Closed

Description

@caomengxuan666

Found by ecosweep4-B triage lane (wt23/bats364, 2026-10-01); bisected with throwaway worktrees. Covers the two red cli_tests fd_redirects cases (c_external_command_uses_persistent_fd_copied_from_stderr, c_external_stderr_uses_persistent_fd_copied_from_stdout).

Reproducer (GNU oracle: WSL GNU Bash 5.3.0)

# helper: external script whose body is `echo external-via-fd`
exec 3>&2; helper >&3

Dual case:

exec 3>&1; helper_err 2>&3   # helper_err writes >&2

GNU: stdout. rubash (since ba69f0d): stderr (wrong).

Notes

  • Builtin-side probes (exec 3>&2; echo x >&3 with the echo builtin) are still correct — the regression is specific to the EXTERNAL-command fd plumbing (the merged-streams rework's single true path loses the fd-3 -> stderr copy for spawned children).
  • Introducing commit: ba69f0d; c70d109 (parent region) verified good; still bad at 2e6b0e9.

Activity

  1. added
    bug
    on Oct 1, 2026
  2. added 2 commits that reference this issue on Oct 1, 2026
  3. caomengxuan666 commented on Oct 1, 2026

    @caomengxuan666
    MemberAuthor

    Landed as 085c6a7 (wt24/regfix lane commit f1a26578). Root cause confirmed at ba69f0d: the deleted ordered capture-replay family was the only consumer resolving >&N dups through ordered redirect state. Fix restores both halves at the fd-resolution root: plan_external_stdio's resolve_dup_source now consults the fd table's live ambient bindings (mirroring fd-1/2 seeding, Stdout generation bookkeeping included), and the piped-fallback drain routes through route_builtin_buffered_output. GNU contract: redir.c:1170 dup2 + :1188-1192 no-close-on-exec. 10-case fd matrix byte-identical; the two fd_redirects reds are green; remaining 2 diffs are pre-existing platform limits (foreign child can't receive exec-established numbered fds via std::process) — filed separately. CI green on 085c6a7.

  4. added a commit that references this issue on Oct 1, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions