Skip to content

cli: sync PWD env var with --cwd chdir#30458

Open
robobun wants to merge 3 commits into
mainfrom
farm/97a34fd9/cwd-pwd-env
Open

cli: sync PWD env var with --cwd chdir#30458
robobun wants to merge 3 commits into
mainfrom
farm/97a34fd9/cwd-pwd-env

cli: sync PWD env var with --cwd chdir

4a1948c
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed May 17, 2026 in 34m 45s

Code review found 1 important issue

Found 4 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 0
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/runtime/cli/Arguments.rs:1632-1635 UB: write through shared-reference-derived pointer in patch_windows_environ_snapshot

Annotations

Check failure on line 1635 in src/runtime/cli/Arguments.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

UB: write through shared-reference-derived pointer in patch_windows_environ_snapshot

Writing through `env.as_ptr() as *mut *mut c_char` is UB under Stacked Borrows / Tree Borrows: `env` is a `&'static [*mut c_char]` built via `slice::from_raw_parts` (src/bun_core/lib.rs:245-253), so `.as_ptr()` carries `SharedReadOnly` provenance and the cast doesn't change that — Miri will reject the write at line 1634. The `bun_core::os` module already stores the raw `*mut *mut c_char` in `ENVIRON` precisely to avoid this round-trip; either expose an `environ_raw()`/`environ_mut()` accessor an