Skip to content

fix(executor): keep __RUBASH_FD_* delivery stamps out of the non-respawn strip (Refs #3856) - #3857

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/3856-fd-delivery-strip
Nov 17, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/3856-fd-delivery-strip

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Fixes #3856

Summary

0a405d8a0 (#3736, Refs #3049) added __RUBASH_FD_ to compound_exec::fork_respawn_transport_key. Executor::new_inner (init.rs:536-546) strips every matching key for any birth that is not a validated internal respawn — before the env_vars.retain at init.rs:1292 can collect them into inherited_fd_handles. exec/external/comsub/pipeline children are never respawns, so all fd>=3 delivery through the env channel died. On Windows this is total (env channel is the only transport; inherited_open_fds is always empty there, fd_table.rs:748); on unix the pin+adoption path masks it.

The __RUBASH_FD_* keys are per-spawn delivery stamps minted fresh by the direct spawner for THIS child and consumed+stripped at entry — not respawn residue — so they do not belong to the #3049 family (whose leak was *_VARS attribute strings imported by VarTable::from_values).

Fix: drop the __RUBASH_FD_ prefix from fork_respawn_transport_key and document the carve-out. __RUBASH_FD_AT_STAMPED, __RUBASH_FD_HANDLE_/WHANDLE_/PATH_/WPATH_N all survive to their unconditional consumers again.

Evidence

  • Bisect: good e3a7b7b3a → bad 0a405d8a0 → still bad 3d8c9ff8 (master).
  • tests/issue3311_exec_child_fd_delivery: 4/4 red on master (rc=1 f=[] vs expected rc=0 f=[x]) → 4/4 green here.
  • cargo test --lib fd_: 15/15.
  • Probe target/scratch-i3/rubash-3560-exec.sh: master all rc=1; here exec-own rc=0 f=[x], exec-amb rc=0 f=[amb], plain-own rc=0 f=[p].

Test plan

  • cargo build --locked --bin rubash
  • cargo test --test issue3311_exec_child_fd_delivery 4/4
  • cargo test --lib fd_ 15/15
  • rustfmt --check clean on touched file
  • unix-side cargo test --lib + issue3049 bats cell (cfg(unix), needs WSL build — flagged for captain)

Unblocks verification of #3560 (command-local N>&- must revoke the delivered fd).

…awn strip (Refs #3856)

0a405d8 (#3736) added __RUBASH_FD_ to fork_respawn_transport_key, so
Executor::new_inner deleted every fd-delivery stamp for any birth that
is not a validated internal respawn — before init.rs could collect them
into inherited_fd_handles. exec/external/comsub/pipeline children are
never respawns, so all fd>=3 delivery through the env channel died on
Windows (unix masks it via pin+adoption). The keys are per-spawn
delivery minted fresh for THIS child and consumed+stripped at entry —
not respawn residue — so they do not belong to the #3049 family.

Verified: tests/issue3311_exec_child_fd_delivery 4/4 red->green;
exec-own/exec-amb/plain-own fd>=3 writes reach children again.
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 17, 2026 15:44
@caomengxuan666
caomengxuan666 merged commit d5c910d into master Nov 17, 2026
10 of 12 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.

[bug] fd>=3 delivery to children dead on Windows since #3736: fork_respawn_transport_key strips __RUBASH_FD_* for every non-respawn birth

1 participant