anthropics / anthropics/claude-code

Deterministic SIGSEGV on claude CLI startup (free/__newlocale/pthread_once)

Đang mở
#89,366 7 bình luận 4 reaction 0 người được giao Xem trên GitHub
area:core area:packaging bug has repro platform:linux
Ngôn ngữ chính
Python
Star
145k
Fork
23.1k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

# Claude Code CLI: deterministic SIGSEGV on process startup

## Summary
Every fresh invocation of the `claude` binary segfaults during startup, before
producing any output — including `claude --version`. Reproduced 100% of the
time (3/3 just now, plus ~20 crashes over a prior ~10-minute window). A
long-running interactive session that has already gotten past whatever
initializes on startup keeps working fine; it's new process launches that die.

## Environment
- OS: Arch Linux (rolling), kernel `7.1.8-arch1-3`
- Two affected installs, same crash signature on both:
- App-installed: `/home/losera/.local/share/claude/versions/2.1.243`
- npm/mise-installed: `/home/losera/.local/share/mise/installs/node/22.23.2/lib/node_modules/@anthropic-ai/claude-code/bin/claude.exe`

## Reproduction
```
$ claude --version
Segmentation fault (core dumped)
```
No arguments needed. Also reliably triggered by the CLI's own shell integration:
the injected `grep`/`find` shell functions shell out to `claude` (as
`ARGV0=ugrep`/`ARGV0=bfs`) to provide fast search — every such invocation
crashed too, until routed around via `command grep`/`command find`.

## Crash signature (from `coredumpctl`, identical across every occurrence)
```
Signal: 11 (SEGV) si_code: SEGV_MAPERR
Stack trace:
#0 free
#1 __newlocale (libc.so.6)
#2 n/a (claude.exe)
#3 n/a (libc.so.6)
#4 pthread_once (libc.so.6)
#5-8 n/a (claude.exe)
#9 n/a (libc.so.6)
#10 pthread_once (libc.so.6)
#11-15 n/a (claude.exe)
#16 __libc_start_main (libc.so.6)
#17 n/a (claude.exe)
```
Pattern: a `pthread_once`-guarded one-time initializer (`__newlocale`) calling
`free()`, crashing with `SEGV_MAPERR` (invalid address, not just a null
deref). Reads like a race or reentrancy bug in one-time locale
initialization — consistent with why a process that's already past init
(this interactive session) keeps running, while every new process launch
(`--version`, or the grep/find subprocess spawns) dies before doing anything
else.

## Timeline
- 19:57:55–20:02:22 EDT — 7 crashes of the top-level `claude` process
(version 2.1.243), one apparently mid-interactive-session in a tmux pane.
- 20:05:19–20:08:06 EDT — crashes shift to the mise-installed
`claude.exe`, including via the grep/find shell-integration subprocess path.
- 20:29:26 EDT (just now) — reconfirmed live: 3/3 fresh `claude --version`
invocations crash identically.

## Impact
- Kills interactive sessions outright when hit mid-session.
- Breaks the CLI's own `grep`/`find` shell integration on every call.
- `claude --version` cannot even report a version right now on this machine.

## Ruled out
- Locale env is standard, not something exotic: `LANG=en_US.UTF-8`, all
`LC_*` inherit from it, `LC_ALL` unset. Not an obvious misconfiguration on
this end, despite the crash being inside `__newlocale`.

## Not yet determined
- Root cause inside `claude.exe` (frames are `n/a` — no symbols available
locally; raw core files are retained under
`/var/lib/systemd/coredump/core.claude*` if useful).
- Whether it's specific to this machine's locale/glibc configuration, or
reproducible more broadly.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Reproduce the crash with `claude --version` and inspect the retained `/var/lib/systemd/coredump/core.claude*` files, comparing both installed binaries and the reported `free`/`__newlocale`/`pthread_once` stack. Determine whether the failure depends on the Arch Linux locale or glibc configuration and identify the startup path responsible. Done means fresh CLI launches and the grep/find shell-integration subprocesses no longer segfault.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
linux
Lĩnh vực
cli, operating-systems
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.