Skip to content

shell: finish the command when its buffered stdin is the last stdio to close - #37799

Open
robobun wants to merge 8 commits into
mainfrom
farm/e830055e/shell-stdin-close-finishes-cmd
Open

shell: finish the command when its buffered stdin is the last stdio to close#37799
robobun wants to merge 8 commits into
mainfrom
farm/e830055e/shell-stdin-close-finishes-cmd

shell: finish the command when its buffered stdin is the last stdio t…

06e57ce
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Aug 12, 2026 in 19m 18s

Code review found 1 important issue

Found 1 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/shell/subproc.rs:308-323 on_close_io holds &mut self across a trampoline that can free self

Annotations

Check failure on line 323 in src/runtime/shell/subproc.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

on_close_io holds &mut self across a trampoline that can free self

`on_static_pipe_writer_done` (and its caller `on_close_io`) take `&mut self`, and the trait shim at `StaticPipeWriterProcess::on_close_io` materialises that borrow via `(*this).on_close_io(kind)`; but the PR's new `y.run(&handle.interp)` can synchronously reach `Cmd::deinit` → `drop(heap::take(child))`, deallocating `*self` while both `&mut self` argument protectors are still on the stack — UB under Stacked/Tree Borrows. The "`&mut self` is dead by NLL here" comment conflates borrow-checker live