Skip to content

Bun segfault (address 0x0) recurring with identical crash signature during long agentic sessions with high subprocess-spawn count #40219

Closed as not planned

Description

@shlomoweb1

Summary

opencode (single instance, no other opencode process running) has crashed twice with an identical Bun segfault signature during long-running agentic sessions with heavy tool-call/subprocess-spawn activity. Both crashes decode to the same bun.report URL, indicating a deterministic, reproducible crash location rather than two unrelated incidents.

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

Crash report: https://bun.report/1.3.14/Ba10d9b296mxGugogC4664tE+ypR0gxx/E4pi4/E6lqggFynh4/E648v2Dszo92CwmzppDksiusC00hhsC8u5gsCy8wK0oxK6iiypCA2AA

Environment

  • opencode version: 1.18.11
  • Embedded Bun: 1.3.14 (Linux x64 baseline)
  • OS: Ubuntu 24.04.1, kernel 7.0.0-28-generic, glibc 2.39
  • CPU: sse42 popcnt avx avx2

Incident 1

  • Single opencode instance running (verified via ps aux afterward — no concurrent instance)
  • Run had been active handling multiple interleaved subagent sessions (multi-agent workflow across several git worktrees) for an extended period
  • At crash time: Elapsed: 6863017ms | User: 5051737ms | Sys: 631260ms, RSS: 0.24GB | Peak: 1.26GB, spawn(435)
  • System memory at time of investigation (shortly after): 15Gi total, ~658Mi free, 375Mi swap in use — under memory pressure, though not from opencode's own RSS

Incident 2 (same crash signature)

  • Also single instance (confirmed no concurrent opencode process)
  • Elapsed: 5203283ms | User: 5746267ms | Sys: 651745ms, RSS: 0.28GB | Peak: 1.69GB
  • jsc spawn(10273) — over 10k child processes had been spawned by this Bun process over the session
  • fetch(725) network requests
  • Session log shows the process was mid-loop on a single subagent session (agent=general mode=subagent), doing rapid consecutive tool-call steps (edits, bash, chrome-devtools calls) roughly every 3–10 seconds for the run's duration, each triggering opencode's per-step git snapshot tracking (a git subprocess spawn logged as tracking hash=... on nearly every step)
  • The structured log (~/.local/share/opencode/log/opencode.log) simply stops mid-step with no shutdown/error entry, consistent with an abrupt native crash rather than a JS-level exception

Observations / possible contributing factors

  1. Both crashes occurred after long-running sessions with very high cumulative subprocess-spawn counts (435 and 10,273 respectively) — opencode's per-tool-call-step git snapshot tracking spawns a git subprocess on nearly every step, in addition to whatever the agent's own bash/tool calls spawn.
  2. System-wide memory pressure was present in at least one incident (658Mi free of 15Gi), though opencode's own RSS was modest (<2GB peak).
  3. Not caused by multiple concurrent opencode instances — verified single process both times.
  4. Identical bun.report hash across two separate incidents suggests a deterministic crash path (same code location), not a random race — but I don't have access to the decoded native stack trace (the bun.report link only shows a "crash report sent" confirmation page, not the trace itself).

What I've ruled out

  • Multiple concurrent opencode processes writing to the same sqlite db (verified only one process running in both incidents)
  • An unrelated corrupted git object in ~/.local/share/opencode/snapshot/.../objects/ causing repeated hourly git repack failures — real issue, present in logs, but timestamps don't correlate with either crash

Trimmed log excerpts (structured log, redacted)

These are the last lines from ~/.local/share/opencode/log/opencode.log for each crashing run, right up to where the log simply stops (no panic/shutdown line is ever written — the structured logger doesn't capture the native crash, it just goes silent). Paths referencing unrelated private repos have been redacted; everything diagnostically relevant (run/session ids, step cadence, tool/stream activity) is intact.

Incident 1 — run=8f05b4e6, ends 2026-08-02T17:50:55.588Z
timestamp=2026-08-02T17:50:18.376Z level=INFO run=8f05b4e6 message=evaluated permission=bash pattern="sleep 12" action.action=allow
timestamp=2026-08-02T17:50:18.376Z level=INFO run=8f05b4e6 message=evaluated permission=bash pattern="pdftoppm -png -r 96 deco-variants.pdf var" action.action=allow
timestamp=2026-08-02T17:50:30.518Z level=INFO run=8f05b4e6 message=loop session.id=ses_03c883f02ffev4rbDNAyltf27u step=190
timestamp=2026-08-02T17:50:30.576Z level=INFO run=8f05b4e6 message=process session.id=ses_03c883f02ffev4rbDNAyltf27u messageID=msg_fc3994883001vePw25Zq9CLV9D
timestamp=2026-08-02T17:50:30.577Z level=INFO run=8f05b4e6 message=stream providerID=opencode modelID=deepseek-v4-flash-free session.id=ses_03c883f02ffev4rbDNAyltf27u small=false agent=general mode=subagent
timestamp=2026-08-02T17:50:31.127Z level=ERROR run=8f05b4e6 message="stream error" session.id=ses_03c883f02ffev4rbDNAyltf27u error.error="AI_APICallError: Rate limit exceeded. Please try again later."
timestamp=2026-08-02T17:50:54.863Z level=INFO run=8f05b4e6 message=loop session.id=ses_03c887e21ffeOgoVfbLQBiHwWF step=213
timestamp=2026-08-02T17:50:54.921Z level=INFO run=8f05b4e6 message=process session.id=ses_03c887e21ffeOgoVfbLQBiHwWF messageID=msg_fc399a79e001JpI4GFa4X0UK5W
timestamp=2026-08-02T17:50:54.921Z level=INFO run=8f05b4e6 message=stream providerID=opencode modelID=deepseek-v4-flash-free session.id=ses_03c887e21ffeOgoVfbLQBiHwWF small=false agent=general mode=subagent
timestamp=2026-08-02T17:50:55.588Z level=ERROR run=8f05b4e6 message="stream error" session.id=ses_03c887e21ffeOgoVfbLQBiHwWF error.error="AI_APICallError: Rate limit exceeded. Please try again later."
--- [log ends here — process crashed silently; next log line is a fresh instance starting 49s later] ---

Notable: two different subagent sessions in the same run both hit Rate limit exceeded within ~24s of each other, immediately before the process died.

Incident 2 — run=46b9e069, ends 2026-08-03T05:23:45.243Z
timestamp=2026-08-03T05:23:31.876Z level=INFO run=46b9e069 message=tracking hash=27da42628669af017b9d97932cf8c662f5d47889 cwd=<project>/izkor
timestamp=2026-08-03T05:23:31.911Z level=INFO run=46b9e069 message=loop session.id=ses_03a235b15ffe7x5NafNq3gRolO step=336
timestamp=2026-08-03T05:23:31.997Z level=INFO run=46b9e069 message=process session.id=ses_03a235b15ffe7x5NafNq3gRolO messageID=msg_fc613c3df001To1zWO1kqZABU0
timestamp=2026-08-03T05:23:31.998Z level=INFO run=46b9e069 message=stream providerID=opencode modelID=deepseek-v4-flash-free session.id=ses_03a235b15ffe7x5NafNq3gRolO small=false agent=general mode=subagent
timestamp=2026-08-03T05:23:38.463Z level=INFO run=46b9e069 message=evaluated permission=bash pattern="grep -rn 'Title' <redacted-external-repo>/info.go" action.action=allow
timestamp=2026-08-03T05:23:38.571Z level=INFO run=46b9e069 message=tracking hash=27da42628669af017b9d97932cf8c662f5d47889 cwd=<project>/izkor
timestamp=2026-08-03T05:23:38.608Z level=INFO run=46b9e069 message=loop session.id=ses_03a235b15ffe7x5NafNq3gRolO step=337
timestamp=2026-08-03T05:23:41.979Z level=INFO run=46b9e069 message=evaluated permission=bash pattern="grep -n 'Title' <redacted-external-repo>/info.go" action.action=allow
timestamp=2026-08-03T05:23:42.127Z level=INFO run=46b9e069 message=loop session.id=ses_03a235b15ffe7x5NafNq3gRolO step=338
timestamp=2026-08-03T05:23:45.147Z level=INFO run=46b9e069 message=loop session.id=ses_03a235b15ffe7x5NafNq3gRolO step=339
timestamp=2026-08-03T05:23:45.220Z level=INFO run=46b9e069 message=tracking hash=27da42628669af017b9d97932cf8c662f5d47889 cwd=<project>/izkor
timestamp=2026-08-03T05:23:45.239Z level=INFO run=46b9e069 message=process session.id=ses_03a235b15ffe7x5NafNq3gRolO messageID=msg_fc613f792001zTDso3CX0q0ARc
timestamp=2026-08-03T05:23:45.239Z level=INFO run=46b9e069 message=stream providerID=opencode modelID=deepseek-v4-flash-free session.id=ses_03a235b15ffe7x5NafNq3gRolO small=false agent=general mode=subagent
timestamp=2026-08-03T05:23:45.243Z level=INFO run=46b9e069 message="llm runtime selected" llm.runtime=ai-sdk llm.provider=opencode llm.model=deepseek-v4-flash-free
--- [log ends here — crashed right after starting a new LLM stream, mid-loop, step 339, ~10s cadence] ---

Notable: this was a tight loop of small tool-call steps every 3–10s (edits, bash, git-snapshot tracking on every step) for the duration of an 87-minute session before dying mid-stream-start.

Request

Since the embedded Bun version is fixed by the opencode release (per the crash page: "The app developer controls which version of Bun is used"), an update would need to come from an opencode release with a newer/patched Bun. Filing this in case it's useful to correlate against other Bun-embedded segfault reports already open against this repo, and in case the bun.report hash is retrievable by maintainers to get the actual native stack trace.

The excerpts above are trimmed/redacted from a much larger structured log that also covers unrelated private projects on my machine. If a maintainer needs the full raw opencode.log (or the sqlite session DB) to dig further, I'm willing to share it under an NDA — happy to coordinate on that separately rather than posting it publicly here.

Activity

  1. github-actions commented on Aug 3, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your crash is distinct (e.g., the identical bun.report hash across two separate incidents is a unique data point), feel free to keep this open and note that in the existing issues or cross-reference them here.

  2. mmdmcy commented on Aug 13, 2026

    @mmdmcy

    I hit two more long-session crashes on OpenCode 1.18.18, and these cores identify a concrete Bun 1.3.14 root cause that is related to this issue but different from the original report's decoded stack.

    Both processes terminated with SIGILL at the same intentional Bun trap:

    core 1: thread 870278 frame 0 = opencode.exe + 0x2407064 (VA 0x2607064)
    core 2: thread 2313947 frame 0 = opencode.exe + 0x2407064 (VA 0x2607064)
    signal: 4 (ILL)
    embedded Bun: 1.3.14
    OpenCode: 1.18.18
    Linux x86-64 baseline
    

    That exact 0x2607064 crash address and the surrounding native path match oven-sh/bun#31159:

    Bun__JSValue__unprotect
    jsc.JSValue.JSValue.unprotect
    runtime.webcore.streams.Result.deinit
    runtime.webcore.ByteStream.deinit
    runtime.webcore.ReadableStream.NewSource(...).decrementCount
    runtime.webcore.ReadableStream.NewSource(...).JSReadableStreamSource.finalize
    

    Bun fixed this use-after-free in oven-sh/bun#31963, merged as oven-sh/bun@7ff1181. StreamError::JSValue could remain parked in ByteStream.pending.result without a GC root; finalization could then unprotect a freed/recycled JS value. The fix roots the value with jsc::strong::Optional and adds test/js/bun/s3/s3-stream-error-gc.test.ts.

    Validation performed locally:

    • Bun 1.3.14 reproduces the upstream regression.
    • 1.4.0-canary.1+b7a043103 contains the fix and passes the regression test.
    • I rebuilt the OpenCode 1.18.18 Linux baseline executable with that canary runtime and resumed both intact sessions.
    • The replacement processes have so far completed more than 45 minutes of sustained history replay, streaming, tool calls, GC/compaction, and subagent work without another core dump.

    OpenCode's current dev branch still pins Bun 1.3.14, and Bun has not yet published a stable release containing 7ff11819. A stable runtime bump once that release exists should remove this confirmed crash path. I would avoid a canary bump unless maintainers explicitly want one.

    References:

  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