Repository navigation
fix(builtins): poison the logical cwd cache when physical pwd resolution fails - #3375
Conversation
…ion fails A failed physical resolution did not propagate to the logical cache's validity: after 'pwd -P' failed in a deleted cwd, later default/'pwd -L' still printed the stale logical string with rc 0. GNU's pwd_builtin (cd.def:457-523) calls resetpwd on sh_physpath failure, which NULLs the_current_working_directory (cd.def:183-191), so later logical faces re-derive via getcwd and fail the same way (common.c:592-624). The fix returns a physical_resolution_failed flag from the pwd executor, clears shell_state.logical_cwd to None on that flag (the resetpwd FREE+NULL), and makes the logical face re-derive through the getcwd gate only in the poisoned state. Refs unixwin#3349 Regression pin tests/issue3349_pwd_poisoned_logical_cache.rs (7 tests; fail-first 2 passed / 5 failed on the unpatched tree, 7/7 pass after; supervisor verified both rounds with the patch method). Adjacent: issue2798 5/5, issue3268 19/19. GNU 5.3.20 oracle (built from third_party/bash) byte-identical on all 7 pin shapes. cargo fmt clean.
|
Captain review: FAIL (2026-11-14) — one hard defect, introduced by this PR, proven on the PR's own head CI. Everything else (mechanism, pin, GNU anchors) passes. F1 — Windows test-compile break, product-code defect in this PRHead CI run 43043432299 (headSha 661afab) has two red legs with one root cause: Windows tests compile check and GNU regression goldens and canaries. Failure log + head source, read first-hand:
Rework spec (mechanical, small)Change the three assertions to compare Not part of this FAILThe two residuals the PR body discloses (the |
|
【WIN-AGENT-AUDIT】 返工续作开工(Wave 4)。回应队长 FAIL 评论 F1:
计划:checkout head 661afab → 修三处断言 → |
…unixwin#3349) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
【WIN-AGENT-AUDIT】 PR #3375 第2轮 — 建议:PENDING(缺腿:终头 CI 与队长聚焦复核腿) 机制核查:
腿:
F 点回应:
续作记录:
未跑/VOID 的腿:
|
|
【WIN-AGENT-BATCH-SUMMARY】
阻塞/欠账项:
|
…o/rubash into rework-3375
|
【WIN-AGENT-REWORK】 PR #3375 第3轮 — 建议:PASS(终头 CI 归类完毕 + 合并冲突修复两轮已推 fork) 续作记录(本轮新推三 commit,均为叠加):
终头 CI 按名归类(run 43688463672):红 = GNU goldens / Rust tests / Rust tests macOS,红名各仅 {issue2875_input_procsub_child_runs_as_rubash_shell} → 全基线;niubash builds / API ledger / compat CLI / cross-target×2 / shell tests / Windows compile 全绿——两断点闭合。 队长 PENDING 复核项逐条回应:
判词翻 PASS,按协议 squash 合并。 |
Fixes #3349
What was fixed
After
pwd -Pfailed in a deleted cwd, later defaultpwd/pwd -Lstill printed the stale logical string with rc 0. The physical face's failure never propagated to the logical cache's validity.GNU's
pwd_builtin(builtins/cd.def:457-523) callsresetpwdonsh_physpathfailure, which frees and NULLsthe_current_working_directory(cd.def:183-191) — the poisoning is that NULL, not the diagnostic itself. Later logical faces then hit thetcwd == 0arm and re-derive viagetcwd, failing the same way (builtins/common.c:592-624,pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory, rc 1).$PWDitself is untouched byresetpwdand keeps its stale value, as in GNU.The fix: the pwd executor returns a
physical_resolution_failedflag (PwdOutcome), andexecute_pwd_with_ioclearsshell_state.logical_cwdtoNoneon that flag (theresetpwdFREE+NULL) — the single dispatch entry all pwd faces go through. In the poisoned state the logical face goes through thegetcwdgate and fails with the same diagnostic; with a cached value the earlier arms print as before (#2798's对照格 is unaffected), and when the session cwd is resolvable it falls through to the physical display. Poisoning follows Clone fork boundaries, so a subshell's failure poisons only the clone, never the parent.What was deleted
Nothing. No files, features, or tests were removed.
Verification (all run, per-item counts)
tests/issue3349_pwd_poisoned_logical_cache.rs: 7/7 pass (Unix-only, script-file style, GNU cross-checked). Fail-first on the unpatched tree (supervisor re-ran with the patch method): 2 passed / 5 failed — the 5 chained cells printed the stale string with rc 0.third_party/bash): all 7 pin shapes byte-identical on stdout/stderr. One deviation noted in the pin comments: GNU'scdentry prints one extrachdir: error retrieving current directory: getcwd: …diagnostic in the poisoned state (see owed)...按物理路径解析,默认与 -L 下均偏离逻辑目录 #2796 12/12, 已删 cwd 下进程内路径串解析同族残差:comsub 内 cat、cd ..、壳侧输入重定向、模拟 cp 操作数面 #3268 deleted-cwd cd redirects 19/19 (supervisor re-ran [bug] pwd -P 在 cwd 已删时不报 getcwd 错,静默印陈旧目录且 rc 0 #2798 5/5 and 已删 cwd 下进程内路径串解析同族残差:comsub 内 cat、cd ..、壳侧输入重定向、模拟 cp 操作数面 #3268 19/19), [P0] Windows 原生 source nvm.sh v0.40.8 自动载入挂起:PWD 盘符形态使 nvm_find_up 死循环(GNU 同 PWD 亦挂;Linux 原生不受影响;1.4.0 阻塞) #537 2/2,pwd.rsunit tests 2/2.cargo build -j 2clean,cargo fmt --checkclean.src/lexer/continuation.rsuntouched.Owed
chdir:diagnostic at thecdentry (same-wave residual, needs a separate issue or the captain's call): in the poisoned state GNU's everycdentry goes throughget_working_directory("chdir")(cd.def:529-534) and printschdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directorybefore continuing (the move itself succeeds); rubash'scddoes not print it in this state. The pin file's cell 5 comment records the deviation.same_filere-verification arm (cd.def:499-506): underset -o posixGNU checkssame_file(".", tcwd)on everypwdand goes toresetpwdin a deleted cwd; rubash has not implemented that arm, sopwd -Lstill prints the stale string in POSIX mode. Unprobed, unfixed, adjacent face in the same function.__RUBASH_PHYSICAL_PWDmarker the physical face returns the stored value directly without canonicalizing, so there is no failure and no poisoning; unverifiable on this Linux VM.