Skip to content

fix(timeout): children resolve with Win32 PATH semantics and the package-sibling fallback (main CI regression from #1567) - #1569

Merged
caomengxuan666 merged 2 commits into
mainfrom
fix/timeout-child-resolution
Nov 11, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
fix/timeout-child-resolution

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Fixes the main CI regression introduced by the wave3b timeout wiring (#1567): 25 ctest failures on the clean runner (build-windows (x64, x64, x64, default) red since e466808), all in the timeout family — timeout.timeout_basic/timeout_signal_kILL/... (22) and childproc.timeout_bare_name_colliding_with_system32_resolves_from_path/timeout_posix_mixed_path_entries_are_resolved/timeout_batch_script_from_path_routes_through_interpreter (3).

Root cause (two stacked defects, both in the rust2 child-resolution path)

  1. Case-sensitive PATH lookup over a Win32 block. The bridge snapshots GetEnvironmentStringsW verbatim; the entry is spelled however the parent wrote it — Path from a PowerShell/cmd CI runner parent, PATH from an MSYS one. MapEnv::get is an exact POSIX-style match, so resolve_child missed the block's only PATH entry and invented the System32/Windows default: wrapped sleep.exe/echo.exe → timeout: failed to run command 'sleep.exe': No such file or directory (127); timeout 5 where resolved System32\where.exe, which exits 2 with no arguments — exactly the observed rc shapes. Green locally for the worst reason: a Git Bash parent exports uppercase PATH (plus an installed entry-link state on PATH).
  2. No same-package sibling resolution. Even with correct casing, a clean runner has no package dir on PATH, so a bare echo.exe/sleep.exe wrapped by timeout cannot resolve. GNU never hits this because on POSIX the package prefix IS on PATH by construction (/usr/bin).

Fix (option a — dispatcher-own-children fallback; option b entry-link materialization rejected)

  • winux_core::win32_env_get — case-insensitive, first-occurrence-wins lookup (GetEnvironmentVariableW semantics) as an explicit resolution-only tier; EnvSource::get stays exact because environ-semantics commands keep GNU's POSIX match (printenv gfoo vs GFoo = gate row pe10-lowercase, still green). timeout reads PATH/PATHEXT/COMSPEC through it.
  • resolve_child appends the running image's own directory as the LAST search entry for bare names. Windows' own loader blesses this: the CreateProcess legacy search consults "the directory from which the application loaded" (Microsoft Learn, CreateProcess search order, entry 1) — the Windows analog of POSIX's always-on-PATH /usr/bin. PATH stays authoritative (appended last, so shadowing and the GNU 126/127 diagnostics keep their shapes); the fallback only rescues same-package siblings when the package bin dir is not on PATH (portable runs, test rigs, clean runners). Entry-link materialization (option b) was rejected: it cannot help clean-machine multicall/portable runs at all and it couples packaging to a resolution invariant.

Verification

  • Clean-PATH simulation (PATH=System32;PowerShell;Git\cmd only — no package dir, no Git\usr\bin, i.e. stricter than the real runner): the previously failing 25 — in fact all 36 timeout/childproc.timeout_* cases — pass 36/36; pre-fix build fails timeout_basic 127 under the identical simulation.
  • Normal environment: full ctest failing set equals the 20-test pre-existing baseline exactly (zero timeout/childproc entries).
  • Strictly-clean-PATH full ctest: 27 failures, zero in timeout/childproc — the rest are the unwired C++ wrappers (stdbuf/nohup/nice/xargs/time_cmd) that use the C++ childproc PATH-only path this PR does not touch (same class as the regression, separate owner); plus the 20 baseline environment tests.
  • cargo test winux-core + winux-cmds: 341 green (incl. new path_env_casing_does_not_break_child_resolution and win32_env_get_is_case_insensitive_first_match).
  • Gates: run-gate.sh timeout printenv pwd users numfmt — 140 GNU-gated + 17 win-only, all green (pe10-lowercase pins the POSIX exactness that win32_env_get deliberately does not leak into).

Root cause of the #1567 main-CI regression (25 timeout-family ctest
failures on clean runners): the bridge snapshots a Win32 environment
block, whose PATH entry is spelled however the parent wrote it —
"Path" from a PowerShell/cmd runner parent, "PATH" from MSYS — but
MapEnv::get is an exact POSIX-style match. The rust2 timeout missed the
block's only PATH entry, invented the System32/Windows default
(childproc.cppm:274 analog), and every wrapped sibling 127'd
('failed to run command 'sleep.exe''; System32\where.exe even returned
rc 2 with no arguments). Green locally for the worst reason: a Git Bash
parent exports uppercase PATH.

win32_env_get is the case-insensitive, first-occurrence-wins lookup
(GetEnvironmentVariableW semantics) as an explicit resolution-only
escape hatch; EnvSource::get stays exact because environ-semantics
commands must keep GNU's POSIX match — printenv gfoo vs GFoo is gate
row pe10-lowercase and stays green.

Ref: #1567 regression, #1488
…sibling fallback

Two halves of the #1567 main-CI regression fix:

- PATH/PATHEXT/COMSPEC now read through win32_env_get: the spawned
  timeout.exe carries whatever casing its parent used, and a case miss
  fell through to the System32/Windows default before any PATH entry
  was consulted.
- bare-name resolution falls back to the running image's own directory
  after every PATH entry missed (std::env::current_exe parent). GNU
  execvp is PATH-only because on POSIX the package prefix IS on PATH by
  construction (/usr/bin); a Windows multicall package is that analog —
  every entry image (timeout.exe, echo.exe, sleep.exe, ...) is one
  directory, and CreateProcess's own legacy search puts "the directory
  from which the application loaded" first (Microsoft Learn,
  CreateProcess search order). The fallback is appended LAST, so PATH
  shadowing and the GNU 126/127 diagnostics keep their shapes; it only
  rescues same-package siblings when the package bin dir is not on PATH
  (portable runs, test rigs, clean runners).

Tests: path_env_casing_does_not_break_child_resolution (mixed-case
"Path" block resolves a wrapped batch, rc 0) and
win32_env_get_is_case_insensitive_first_match in winux-core. Clean-PATH
simulation (System32+PowerShell+Git\cmd only, no package dir): the 25
previously failing timeout/childproc ctest cases all pass; normal-env
full ctest failing set equals the 20-test pre-existing baseline.

Ref: #1567 regression, #1488
@caomengxuan666

Copy link
Copy Markdown
Member Author

Root-cause evidence chain, for review convenience: on the failing main run (43018585303), timeout 5 sleep.exe printed timeout: failed to run command 'sleep.exe': No such file or directory rc 127 while timeout 5 where (fake-PATH injected) returned rc 2 — the signature of System32\\where.exe with no arguments, i.e. the resolver never saw the block's PATH entry (case miss) and took the System32 default; childproc.timeout_missing_command passed because NotFound-by-either-path still 127s. Local repro: pre-fix build under a clean-PATH ctest fails timeout_basic 127; post-fix build passes 36/36 under the same simulation.

@caomengxuan666
caomengxuan666 merged commit 6e4f795 into main Nov 11, 2026
9 of 10 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 12, 2026
…s duplicate block (#1569 semantics preserved)

E0255: the restored wave4b childproc.rs and timeout.rs both defined
resolve_child / quote_windows_arg / ChildResolve. childproc.rs is the
single authority (the restored wave4b bodies were byte-identical to the
timeout.rs copies modulo pub visibility, so the #1569 win32_env_get
case-insensitive PATHEXT lookup and the package-sibling fallback are
unchanged). timeout.rs keeps only its timeout-specific logic and
delegates via the existing `use crate::childproc::{...}` import; nice.rs
re-points the same import from crate::timeout to crate::childproc.
Pinned by timeout::tests::path_env_casing_does_not_break_child_resolution.
@caomengxuan666
caomengxuan666 deleted the fix/timeout-child-resolution branch November 18, 2026 05:50
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.

1 participant