Skip to content

Segfault in JSC MicrotaskQueue::drain (generator microtasks) on rapid PTY shrink — macOS aarch64, Bun 1.3.14 standalone #35010

Closed as duplicate

Description

@watLr

What happened
opencode 1.18.4 (a Bun 1.3.14 standalone executable, NAPI module loaded) segfaults when its
host terminal is rapidly resized down to extreme sizes (~2 cols × 1 row). The crash is inside
the VM's microtask machinery, not application JS — the VM should surface a catchable error
(e.g. RangeError on stack exhaustion) rather than segfault.

Crash reports (two independent hits, same stack family)

Decoded (first report): Segmentation fault at 0x5084EEFFC —
llint_call_javascript → MicrotaskCall::tryCallWithArguments<JSGenerator…> →
callMicrotask (JSMicrotask.cpp:143) → runInternalMicrotask → MicrotaskQueue::drainImpl<true>
→ VM::drainMicrotasks → Bun::jsFunctionDrainMicrotaskQueue (BunProcess.cpp:3806).
Features: spawn, standalone_executable, workers_spawned, napi_module_register, process_dlopen.

Environment
macOS 15 (Darwin 25.4.0), Apple Silicon. The terminal host is xterm.js inside a Tauri app
(PTY via portable-pty); the process group receives SIGWINCH + TIOCSWINSZ per resize step,
~10–120 ms apart, down to 2×1. Process RSS was ~1.0 GB at the time (this instance's normal
baseline in that workspace — not a leak ramp).

Reproduction honesty
Hit twice in the real app (both reports above). We could NOT isolate a standalone repro:
headless PTY harnesses (single jump to 1×1, 1-col staircase drags at 20–100 ms cadence with
bounces, floor jitter, DSR/XTWINOPS query replies, SGR mouse-motion floods with out-of-range
coordinates) all survive. Whatever the missing ingredient is, it's timing/state-dependent in
the real xterm.js byte stream. Happy to run instrumented builds or gather more data.

Downstream mitigation (for anyone else hitting this)
Host-side: never report a grid below 20×5 to the PTY (real terminals have window minimums;
after flooring, the crash class is unreachable). Implemented in our terminal host.

Activity

  1. github-actions commented on Jul 21, 2026

    @github-actions
    Contributor

    Found 3 possible duplicate issues:

    1. Opencode causing Bun crash #24320
    2. panic(main thread): Segmentation fault at address 0x5 #27463
    3. crash on heavy cpu: hash/avx* tasks #24311

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. github-actions commented on Jul 25, 2026

    @github-actions
    Contributor

    Duplicate of #24320.

    This issue has been automatically closed as a duplicate.

    If this is incorrect, please re-open this issue or create a new one.

    🤖 Generated with Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    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