Repository navigation
WIP: fix #2530 #2531 #2532 fd table faces - #2561
Merged
Merged
Conversation
…ription (rubash#2530) A process born with fd 0 on an O_RDWR file (./child.sh <>file) could read fd 0 but never write it: FdTable::new seeds fd 0 as read=InheritedProcessStdin/write=None and register_inherited_process_fds only adopts fds >= 3, so the write side of the birth descriptor was never claimed. The seed now probes fd 0's live direction (fd_directions) and, when writable, installs a dup of descriptor 0 itself as the write endpoint - one open file description, shared offset, like GNU's r_input_output open (make_cmd.c:682-683 O_RDWR|O_CREAT; redir.c:725 redir_open; redir.c:1160 validates dup sources against the kernel). Second face of the same divergence: the <&N descriptor-dup faces (the fd-0 arm of apply_external_stdin_redirect and the own-input-binding replay) served the dup through open_fd_read_endpoint, the alias-SPELLING dispatch, which re-opens a regular file fresh (redir.c:603/:629 model). A child reading fd 0 through <&0 thus advanced a private offset while its >&0 writes used the true inherited description. Dup faces now take open_fd_read_endpoint_stream - the endpoint's own description - exactly the split that function's contract states; spelling opens keep the reopen wrapper. issue2261_child_script_readwrite_fd0_regressions: 9/9 via build slot.
…ash#2531)
deliver_fd_var_dup's at-position resolutions - (1) a binding this
walk already delivered for the source, (2) the fd-0 replay - stamped
only the channel matching the dup's spelling. The ambient stamp loop
runs BEFORE the walk and had already stamped the var's slot from the
applier's ambient copy of the source (it resolves against the
ambient table only), so the unstamped channel kept the ambient
descriptor: {w}>&9 with 9<f9 bound earlier in the same list wrote
through f9's description but read through the ambient fd 9 copy -
GNU's one ordered walk (redir.c:237) dups the descriptor bound at
the dup's position, whole (dup2, redir.c:1193).
Both rungs now stamp the one resolved description on both env
channels with a single dup (stamp_child_fd_description; the child's
restore pairs equal stamped values into one shared FileFd), the
same shape the numbered walk's <> arm already used.
issue2310_scriptface_fdvar_regressions: 8/8 via build slot.
…nix (rubash#2532)
open_files_limit read only the __RUBASH_ULIMIT_N env cell - the
Windows emulation's store. On Unix the ulimit builtin drives the
real setrlimit (builtins/ulimit.rs plat::set) and stores nothing,
so the allocator always fell back to the 10240 default and a
shell-set ulimit -n never bounded {var} allocation: neither the
EMFILE ceiling (ulimit -n 12: the third exec {c}>>f allocated
instead of failing 'Too many open files') nor the below-base
EINVAL (ulimit -n 6: exec {v}</dev/null allocated instead of
failing 'Invalid argument', GNU redir.c:940-946 F_DUPFD bounded by
the current soft limit).
On Unix the allocator now reads the process rlimit back with
getrlimit(RLIMIT_NOFILE) - the same source the builtin reports
from, so the limit the shell set is the limit the allocator
obeys; RLIM_INFINITY maps to unlimited. The Windows env-cell parse
is unchanged.
issue773_fd_table_capacity_regressions: 6/7 via build slot - both
adjudicated pins pass; the remaining red is
emulated_ulimit_defaults_match_oracle, adjudicated PIN-wrong (it
expects the authoring machine's 10240/1048576; this host's ambient
is 4096/4096 and rubash now reports the true ambient, matching the
oracle here).
caomengxuan666
force-pushed
the
fix/2530-fd-misc
branch
from
November 2, 2026 05:10
1e308d9 to
e9b3d5e
Compare
caomengxuan666
marked this pull request as ready for review
November 2, 2026 05:37
This was referenced Nov 2, 2026
Member
Author
|
[win-acceptance] #2561 — three faces on Windows (no new pin in this PR; verification = batteries ×2 + issue-repro A/B vs WSL GNU 5.3.20):
No BLOCKER to the merge; the shared-offset pair is reported for adjudication. Environment: Windows 10 19045 real machine, MSVC Rust debug build of master b41e8b6 (contains this merge), oracle |
This was referenced Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #2530
Refs #2531
Refs #2532