Skip to content

Bun segfault on graceful shutdown (macOS Apple Silicon, embedded Bun 1.3.14) #31563

Closed as not planned

Description

@andreuSignes

Description

Closing a normal interactive opencode session on macOS Apple Silicon triggers a segmentation fault in the embedded Bun runtime. The process crashes during shutdown with a panic(main thread): Segmentation fault, leaving a zsh: trace trap shell message. The crash is consistent and reproduces on every exit.

This looks like a Bun runtime bug surfacing during opencode's teardown — possibly related to microtask draining, SQLite handle cleanup, or unclosed worker handles. The Bun crash report link is the canonical artifact for diagnosing it.

OpenCode version

1.16.2 (installed via brew install anomalyco/tap/opencode)

Plugins

None — stock config, no MCP servers, no custom subagents.

Steps to reproduce

  1. Install opencode 1.16.2 on macOS Apple Silicon.
  2. Launch a normal interactive session: opencode.
  3. Send a message, wait for the response, then exit the TUI cleanly (e.g. Ctrl+C or /exit).
  4. Observe the panic on shutdown.

The crash does not require any specific prompt content — exiting any session reproduces it.

Screenshot and/or share link

Full crash output:

opencode
                                   ▄
  █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
  █  █ █  █ █▀▀▀ █  █ █    █  █ █  █ █▀▀▀
  ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀

  Session   Auditoría de configuración y estado de opencode
  Continue  opencode -s ses_151d20da1ffeDHyzG177vs8LLi

============================================================

Bun v1.3.14 (0d9b296a) macOS Silicon
macOS v26.5.1
CPU: neon fp aes crc32 atomics
Args: "opencode" "--user-agent=opencode/1.16.2" "--use-system-ca" "--"
Features: Bun.stderr(4) Bun.stdin(4) Bun.stdout(4) abort_signal(3) fetch(475) jsc spawn(45) standalone_executable transpiler_cache(3) virtual_modules(2) workers_spawned(2) workers_terminated
Builtins: "bun:ffi" "bun:main" "bun:sqlite" "node:assert" "node:async_hooks" "node:buffer" "node:child_process" "node:console" "node:crypto" "node:dns" "node:events" "node:fs" "node:fs/promises" "node:http" "node:https" "node:module" "node:net" "node:os" "node:path" "node:process" "node:querystring" "node:readline" "node:stream" "node:stream/consumers" "node:stream/promises" "node:string_decoder" "node:timers/promises" "node:tls" "node:tty" "node:url" "node:util" "node:zlib" "node:worker_threads" "ws" "node:v8" "node:http2" "node:diagnostics_channel" "node:dgram"
Elapsed: 572554ms | User: 106946ms | Sys: 13375ms
RSS: 1.80GB | Peak: 1.81GB | Commit: 0.27GB | Faults: 268 | Machine: 34.36GB

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

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.3.14/Ma10d9b296m5BuhogC______2lkjlD______urh5kD27p5tC+xt2yCm9wnCurghJ22j+c+7v4oBA2CwwggoI

zsh: trace trap  opencode

Bun crash report (canonical):
https://bun.report/1.3.14/Ma10d9b296m5BuhogC______2lkjlD______urh5kD27p5tC+xt2yCm9wnCurghJ22j+c+7v4oBA2CwwggoI

Notable signals from the dump:

  • workers_spawned(2) workers_terminated — the terminated count is missing in the report, suggesting one or more workers were not cleanly stopped before exit.
  • abort_signal(3) is enabled, so the shutdown path goes through signal-driven teardown.
  • bun:sqlite builtin is loaded — SQLite handle cleanup during exit is a plausible contributor.
  • standalone_executable — confirms the binary bundles its own Bun runtime; the system bun (1.3.9 in ~/.bun/bin/) is not involved.

Operating System

macOS 26.5.1 (Darwin), Apple Silicon (M-series)

Terminal

zsh (default macOS shell). Crash reproduces in both Ghostty and macOS Terminal.

Activity

  1. NachoBasilio commented on Jun 26, 2026

    @NachoBasilio

    Seeing the same shutdown crash pattern on Linux under WSL, with an older embedded Bun.

    Environment from the crash dump:

    • OpenCode args show --user-agent=opencode/1.3.15
    • Embedded Bun 1.3.11
    • WSL kernel 6.6.87
    • Linux x64 baseline

    Repro is also simple here:

    1. Start a normal interactive opencode session
    2. Work in the TUI normally
    3. Exit the session cleanly
    4. Bun crashes during shutdown with panic(main thread): Segmentation fault

    Canonical Bun crash report:
    https://bun.report/1.3.11/Ba1af24e28m5HuhogC4ktn4E+ypR____45z1iE45z1iE_45z1iE______m80tiEsi4jrF+895vF0i73qEA2+54Bwtgg/U

    The bun.report page points at Bun::JSNextTickQueue::drain, so this also looks like teardown or event loop cleanup rather than user code.

    Given this and the macOS report above, it looks cross-platform and tied to shutdown in the bundled Bun runtime.

  2. naturedamends commented on Aug 23, 2026

    @naturedamends
    Bun v1.3.14 (0d9b296a) Linux arm64
    Linux Kernel v6.18.39 | musl
    CPU: neon fp crc32
    Args: "opencode" "--user-agent=opencode/1.18.21" "--use-system-ca" "--"
    Features: Bun.stderr(4) Bun.stdin(4) Bun.stdout(4) fetch(74) jsc spawn(24) standalone_executable workers_spawned workers_terminated napi_module_register process_dlopen
    Builtins: "bun:ffi" "bun:main" "bun:sqlite" "node:assert" "node:async_hooks" "node:buffer" "node:child_process" "node:console" "node:crypto" "node:dns" "node:events" "node:fs" "node:fs/promises" "node:http" "node:https" "node:module" "node:net" "node:os" "node:path" "node:process" "node:querystring" "node:readline" "node:stream" "node:stream/consumers" "node:stream/promises" "node:string_decoder" "node:timers/promises" "node:tls" "node:tty" "node:url" "node:util" "node:zlib" "node:worker_threads" "ws" "node:v8" "node:http2" "node:diagnostics_channel" "node:dgram"
    Elapsed: 82807ms | User: 73949ms | Sys: 5252ms
    RSS: 0.20GB | Peak: 0.90GB | Commit: 0.20GB | Faults: 887 | Machine: 3.98GB
    
    panic: Segmentation fault at address 0x8
    oh no: Bun has crashed. This indicates a bug in Bun, not your code.
    
    To send a redacted crash report to Bun's team,
    please file a GitHub issue using the link below:
    
     https://bun.report/1.3.14/La10d9b296mwHugogC+s4jrE+kuU227/lD227/lDumxzqC+t0YutmYA2AQ
    
    oh no: multiple threads are crashing
    panic: Segmentation fault at address 0x8
     https://bun.report/1.3.14/La10d9b296mwnQugogC+s4jrE+kuU227/lD227/lDumxzqC+t0YutmYA2AQ
    

    using the latest version 1.18.21

    this is the first time i have seen this. I just changed my base image from the offical docker file to alpine with the same code. And copying the bun binary over from the offical repo into my alpine container.

  3. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions