[BUG] Bun Bus error crash on macOS Silicon when pasting image (chat:imagePaste)

Status Fixed / completed
Reported on v2.1.87
Maintainer reply None cached
Activity 6 comments · opened Mar 31, 2026 · closed Apr 8, 2026

Description

Claude Code crashes with a Bun Bus error when using the chat:imagePaste action (pasting an image from clipboard). This is a hard runtime crash, not a silent failure — Bun panics and the entire session terminates.

Environment

  • Claude Code version: 2.1.87
  • Bun version (bundled): 1.3.11 (759ce802)
  • OS: macOS 26.3 (Darwin 25.3.0)
  • Platform: macOS Silicon (Apple M4 Pro)
  • RAM: 48GB

Crash Details

Bus error at address 0xBAD4007
Bun v1.3.11 (759ce802) macOS Silicon

Args: "claude" "--dangerously-skip-permissions" "--verbose" "--dangerously-skip-permissions" "--verbose"
Features: Bun.stderr(2) Bun.stdin(2) Bun.stdout(2) abort_signal(16) fetch(14) jsc spawn(28) standalone_executable process_dlopen yaml_parse(222)
Builtins: "bun:main" "node:assert" "node:async_hooks" "node:buffer" "node:child_process" "node:constants" "node:crypto" "node:dns" "node:events" "node:fs" "node:fs/promises" "node:http" "node:https" "node:module" "node:net" "node:os" "node:path" "node:path/posix" "node:path/win32" "node:perf_hooks" "node:process" "node:stream" "node:stream/consumers" "node:timers/promises" "node:tls" "node:tty" "node:url" "node:util" "node:zlib" "ws" "node:http2"
Elapsed: 90411ms | User: 3431ms | Sys: 1046ms
RSS: 0.89GB | Peak: 0.89GB | Commit: 0.90GB | Faults: 72 | Machine: 51.54GB

panic(main thread): Bus error at address 0xBAD4007
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

Bun Crash Report Link

https://bun.report/1.3.11/M_1759ce80mgkgEuhogC________ur1kJ_m45jmDuri6lD+/0w2Cmsz96C27usH__uri6lD+348uCmnu1zCA4Augg11L

Steps to Reproduce

  1. Launch Claude Code on macOS Silicon: claude --dangerously-skip-permissions --verbose
  2. Use the chat:imagePaste action (Cmd+V with an image in clipboard)
  3. Bun crashes with Bus error

Notes

  • The crash happens early in the session (~90 seconds elapsed), so this is not a long-session memory issue
  • The address 0xBAD4007 looks like a sentinel/poison value, suggesting use-after-free or accessing freed memory during image buffer processing
  • Memory usage at crash was modest (0.89GB RSS)
  • Related to #22632 (Bun crash during sessions) but with a specific, reproducible trigger (image paste) and different crash signature (Bus error vs segfault)
  • Several open issues report image paste not working (#39761, #26901, #29776) but none report it causing a full Bun panic

Expected Behavior

Image paste should either work or fail gracefully with an error message, not crash the runtime.

View original on GitHub ↗

6 Comments

asgeirtj · 6 months ago

Additional info from reporter

  • Drag-and-drop image paste works fine — no crash
  • The crash is only triggered by the keyboard shortcut (Cmd+V → chat:imagePaste action)
  • This suggests the bug is in the clipboard-reading code path specifically, not in image processing itself

The keybinding in question (from keybindings.json line 29):

"cmd+v": "chat:imagePaste"
asgeirtj · 6 months ago

Full stack trace from Bun crash report

The reporter also submitted the crash via bun.report. Stack trace confirms the crash is in a NAPI native binding during clipboard read:

Bus error at address 0x0BAD4007

- 8 unknown/js code
- NapiClass.cpp:68: long long Zig::NapiClass_ConstructorFunction<false>
- 1 unknown/js code
- jsc_llint_commonCallOp (LowLevelInterpreter64.asm)
- llint_call_javascript
- JSMicrotask.cpp:132: JSC::runInternalMicrotask
- VM.cpp:1437: JSC::VM::drainMicrotasks
- BunProcess.cpp:3511: Bun::jsFunctionDrainMicrotaskQueue
- 2 unknown/js code
- llint_call_javascript
- Interpreter.cpp:1320: JSC::Interpreter::executeCallImpl
- CallData.cpp:70: JSC::call

Root cause appears to be: A NAPI class constructor (NapiClass_ConstructorFunction) is called with a bad pointer (0xBAD4007 — a sentinel/poison value), suggesting the native clipboard module returns or accesses freed/invalid memory when reading image data from the macOS clipboard via Cmd+V.

Note: This is in the bundled Bun standalone executable — updating system Bun has no effect. The fix needs to come from either:

  1. Claude Code updating its bundled Bun version
  2. Fixing the native clipboard integration code
  3. An upstream Bun fix for NAPI class construction with clipboard data
DanielJoyce · 6 months ago

It's what they get for using Bun/zig.

asgeirtj · 6 months ago

Root cause identified: Bun 1.3.11 NAPI crash — fixed in 1.3.12 canary

Summary

The crash is a Bun 1.3.11 bug in NAPI error handling, not a Claude Code bug. When new ImageProcessor() throws an error, Bun 1.3.11 dereferences a poison pointer (0xBAD4007) and panics instead of propagating the JS exception. Bun 1.3.12 canary already fixes this — the same code returns a normal error with no crash.

The regression was exposed by v2.1.83 (March 25), which changed native module loading from eager (at startup) to lazy (on first use). This moved the ImageProcessor construction from startup — where errors were handled — to the Ctrl+V code path, where the Bun panic kills the process.

Reproduction (standalone, no Claude Code needed)

  1. Extract image-processor.node from the Claude standalone binary (it's an embedded Mach-O dylib in the __BUN segment at offset 0xb8111eb, 1652KB, links against AppKit/CoreGraphics/ImageIO)
  1. Run with Bun 1.3.11:
const m = require("/path/to/image-processor.node");
new m.ImageProcessor(); // → Bus error at 0xBAD4007, process killed
  1. Run the exact same code with Bun 1.3.12 canary:
const m = require("/path/to/image-processor.node");
new m.ImageProcessor(); // → Error: "Failed to create reference from Buffer" (graceful)
  1. Run with Node.js 22:
const m = require("/path/to/image-processor.node");
new m.ImageProcessor(); // → Error: "Failed to create reference from Buffer" (graceful)

Fix

Claude Code needs to update its bundled Bun from 1.3.11 to 1.3.12+. The NAPI crash fix is already in the 1.3.12 canary. Once the error is thrown as a JS exception instead of a Bus error, Claude's existing fallback code path should handle it and image paste should work normally.

Environment

  • macOS 26.4 (Tahoe), Apple M4 Pro — macOS 26 has been installed since August 2025, image paste worked fine until v2.1.83
  • SIP disabled (verified not the cause — the standalone reproduction crashes regardless)
  • Crash confirmed on v2.1.87, v2.1.91, v2.1.92, and v2.1.96 — all bundle Bun 1.3.11

Timeline

| Date | Event |
|------|-------|
| Mar 25 | v2.1.83 released — native module loading changed from eager to lazy |
| ~Mar 25-29 | Image paste crash begins |
| Mar 29 | v2.1.87 — version in original bug report |
| Apr 8 | Confirmed still crashes on v2.1.96; root cause identified and fix verified on Bun 1.3.12 canary |

asgeirtj · 6 months ago

Fixed in https://github.com/anthropics/claude-code/releases/tag/v2.1.97

Probably with:

  • Improved image handling: pasted and attached images are now compressed to the same token budget as images read via the Read tool
github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.