Skip to content

TUI crashes (Bun segfault) when the terminal shrinks to extreme sizes (~2×1) #38199

Description

@watLr

What happened
Dragging the pane hosting opencode 1.18.4 down to an extreme size (approaching 2 cols × 1 row,
rapid SIGWINCH/TIOCSWINSZ stream) crashes the process — "Bun has crashed / Segmentation fault",
exit 1. Two independent hits, same stack family (JSC microtask drain, generator microtasks):

Environment: macOS aarch64, host = xterm.js in a Tauri app over a PTY (portable-pty).
A session was open (conversation view rendered). Filed the VM side as oven-sh/bun#35010 as well —
a Bun VM shouldn't segfault on whatever the TUI does — but opentui likely also wants a
defensive minimum-size clamp in its layout so pathological grids can't drive that path.

Repro honesty: reliable in our real app at extreme shrink; ~10 headless PTY variants
(staircase drags, floor jitter at 1–4 cols, query replies, mouse-motion floods) did NOT
reproduce, so exact timing/state in the terminal byte stream matters.

Workaround that works: floor the grid the host reports to the PTY (we use 20×5 and clip
visually below that) — real terminals never offer a TUI 2×1 either.

Activity

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