mirror of
https://github.com/oven-sh/bun
synced 2026-02-18 23:01:58 +00:00
When `setupIOBeforeRun()` fails in `runFromJS()` (e.g., stdout/stderr closed on Windows), the error path called `#deinitFromExec()` which freed the interpreter struct via `allocator.destroy(this)`. The GC would later finalize the JSShellInterpreter wrapper, accessing the already-freed memory and causing a segfault. Fix: use `#derefRootShellAndIOIfNeeded(true)` instead, which cleans up runtime resources (IO, shell env) and sets `cleanup_state` to `.runtime_cleaned`, deferring struct deallocation to the GC finalizer. Co-Authored-By: Claude <noreply@anthropic.com>