[BUG] Bun v1.4.0 segfault (SIGSEGV at 0x0) when Claude Code's working directory is deleted mid-session (WSL2)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
Claude Code (running on the bundled Bun runtime) crashes with a segmentation fault at address 0x0 on the main thread when the current working directory it is running in gets removed while the session is active. Bun itself reports the fault ("Bun has crashed. This indicates a bug in Bun, not your code.") and produces a core dump.
Environment
- Runtime: Bun v1.4.0 (eb835313a) Linux x64 (baseline)
- Feature flag present in banner:
claude_code - OS: WSL2, Kernel v6.6.114, glibc v2.35
- CPU features: sse42 popcnt avx avx2
- Machine RAM: ~16.77 GB
- Invocation args:
claude
What happened
A Claude Code session ran to completion (a git commit + push task finished normally). Immediately afterward, the process panicked.
Root cause / relevant clue
The crash is triggered by the current working directory being removed out from under the running process. Immediately before and after the crash, direnv repeatedly failed with:
direnv: error LoadConfig() Getwd failed: "getwd: no such file or directory"
getwd: no such file or directory confirms the process's CWD no longer exists. The runtime appears to segfault rather than handling the deleted/invalid working directory gracefully.
Impact
- Session terminates abnormally with a core dump.
- A Bun crash-report link is generated automatically at exit (Bun's
bun.reportURL).
Notes
- Since Bun reports this as a Bun-level fault, it may also be worth filing/cross-linking upstream at the Bun issue tracker, but it surfaces entirely through the Claude Code CLI.
- Redacted for privacy: working-directory path, repository/remote URLs, commit hashes, and username/hostname have been removed from this report.
What Should Happen?
Claude should display a "Retry or Exit" option; or shutdown gracefully with a clear error message (e.g. "working directory no longer exists") instead of crashing hard.
Error Messages/Logs
panic(main thread): Segmentation fault at address 0x0
oh no: Bun has crashed. This indicates a bug in Bun, not your code.
...
Segmentation fault (core dumped)
Runtime stats reported at crash time:
Elapsed: 10503424ms User: 127593ms Sys: 22644ms
RSS: 0.24 GB | Peak: 0.51 GB | Commit: 3.38 GB | Faults: 421 | Machine: 16.77 GB
(Elapsed ~2.9h indicates a long-lived session before the crash.)
Steps to Reproduce
Steps to reproduce
- Start Claude Code in a working directory.
- While the session is still running, delete (remove) the folder Claude is currently working in from outside the session.
- Claude Code segfaults (SIGSEGV at 0x0) / Bun crashes.
Claude Model
Other
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.223
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗