anomalyco / anomalyco/opencode
Bun segfault (address 0x0) recurring with identical crash signature during long agentic sessions with high subprocess-spawn count
@jlongster is already working on this.
Since Aug 3, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
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.
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
opencodeinstance running (verified viaps auxafterward — 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.69GBjsc spawn(10273)— over 10k child processes had been spawned by this Bun process over the sessionfetch(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 (agitsubprocess spawn logged astracking 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
- 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
gitsubprocess on nearly every step, in addition to whatever the agent's own bash/tool calls spawn. - System-wide memory pressure was present in at least one incident (658Mi free of 15Gi), though opencode's own RSS was modest (<2GB peak).
- Not caused by multiple concurrent opencode instances — verified single process both times.
- Identical
bun.reporthash 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 (thebun.reportlink only shows a "crash report sent" confirmation page, not the trace itself).
What I've ruled out
- Multiple concurrent
opencodeprocesses 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 hourlygit repackfailures — 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.