omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Ghostty terminal keybind launches single-instance mode that can crash all windows

Open nikitalbnv opened this issue 7 months ago • 8 comments

Summary

On my Omarchy install, the terminal keybind launches Ghostty through xdg-terminal-exec. That uses the Ghostty desktop file, which launches Ghostty with --gtk-single-instance=true.

When I run OpenCode inside tmux from a Ghostty window opened this way, Ghostty can crash. Because it is single-instance mode, all Ghostty windows from that shared process can close.

If I launch Ghostty by typing ghostty in another terminal, the same OpenCode plus tmux flow does not crash.

What I expected

The terminal keybind should launch Ghostty the same way as typing ghostty, or at least should not force a mode that can take down every Ghostty window when one surface crashes.

What happened

The keybind path launches:

/usr/bin/ghostty --gtk-single-instance=true

Typing ghostty launches:

/usr/bin/ghostty

The --gtk-single-instance=true path is the one that crashes all shared Ghostty windows for me.

Reproduction

On Omarchy with Ghostty as the default terminal:

  1. Press the terminal keybind.
  2. Run:
tmux
opencode
  1. Interact with OpenCode.
  2. Ghostty can crash. In single-instance mode, other Ghostty windows from the same process can close too.

Direct launch works:

ghostty

Then:

tmux
opencode

This does not crash for me.

Evidence

Omarchy keybind uses xdg-terminal-exec:

$terminal = uwsm-app -- xdg-terminal-exec
bindd = SUPER, BACKSPACE, Terminal, exec, $terminal --working-directory="$(omarchy-cmd-terminal-cwd)"

xdg-terminal-exec --print-cmd returns:

/usr/bin/ghostty
--gtk-single-instance=true

The selected desktop file is:

/usr/share/applications/com.mitchellh.ghostty.desktop

It has:

Exec=/usr/bin/ghostty --gtk-single-instance=true

Local workaround

I added a user desktop file override:

~/.local/share/applications/com.mitchellh.ghostty.desktop

With:

Exec=/usr/bin/ghostty
DBusActivatable=false

After that, xdg-terminal-exec --print-cmd returns:

/usr/bin/ghostty

Now the terminal keybind works and the OpenCode plus tmux flow is stable.

Versions

Omarchy on Arch Linux
Hyprland on Wayland
Ghostty 1.3.1-arch2
tmux 3.6a
OpenCode 1.14.25

Related

I also opened a Ghostty discussion because Ghostty should not segfault either:

https://github.com/ghostty-org/ghostty/discussions/12460

nikitalbnv avatar Apr 25 '26 19:04 nikitalbnv

Second, simpler reproduction — same crash

Hit this same crash twice on my machine, four days apart, with a trigger that doesn't need tmux or OpenCode — just opening a second terminal window while one is already running:

Ghostty 1.3.1-2 (Omarchy/Arch)

Aug 10 14:49:03 and Aug 14 23:36:48 — both segfaults happened a few seconds after xdg-terminal-exec launched a second ghostty --gtk-single-instance=true process while the first was still running. Single-instance mode forwards that as an "open new surface" activation into the existing process, and the crash happens there.

Both crashes are the same fault, down to the instruction:

kernel: io[16502]: segfault at 108 ip 000055b4dda9590d ... in ghostty[151b90d,...]
kernel: io[288391]: segfault at 108 ip 000055b6a6a0590d ... in ghostty[151b90d,...]
  • Same crashing thread (io) both times
  • Same binary offset (ghostty+0x151b90d) both times
  • Same fault: read of address 0x108 (near-null pointer + small struct-field offset), page-not-present

That the offset is identical across two independent runs four days apart (with an intervening mesa/nvidia/glibc/glib2/wayland update on Aug 14 that didn't change it) says this is a deterministic bug in the single-instance "new surface" activation path in the io thread, not something env/timing-dependent — and it doesn't need tmux or any particular app inside the terminal to trigger, just a second launch while single-instance mode is active.

Confirmed the workaround from this thread works: overriding ~/.local/share/applications/com.mitchellh.ghostty.desktop with Exec=/usr/bin/ghostty (no --gtk-single-instance=true) and DBusActivatable=false avoids the crash entirely, since each window is now its own process.

ghostty binary is stripped with no debuginfod symbols available, so I can't name the function — only the offset, thread, and fault address above.

Filed by Claude Sonnet 5 via Claude Code.

manrods avatar Aug 15 '26 02:08 manrods

Additional root-cause evidence from another occurrence

I hit the same crash on 2026-08-30 with Omarchy 4.0.1-1 and Ghostty 1.3.1-2:

process: /usr/bin/ghostty
command: /usr/bin/ghostty --gtk-single-instance=true --working-directory=/home/<user>
signal:  SIGSEGV / SEGV_MAPERR
thread:  io
kernel:  segfault at 108
offset:  ghostty+0x151c90d

Inspecting the retained core showed:

WriteQueue head = 0
WriteQueue tail = 0
r14 = 0
faulting instruction: mov 0x108(%r14), %rcx

The instruction maps to libxev's inlined WriteQueue.pop(), reading the WriteRequest.next field at offset 0x108 after an epoll completion arrives for an already-empty PTY write queue. This matches the known upstream bug and reproduction in mitchellh/libxev#234:

https://github.com/mitchellh/libxev/issues/234

Ghostty 1.3.1 pins libxev commit 34fa50878aec6e5fa8f532867001ab3c36fae23e.

This also identifies an Omarchy-side trigger beyond the single-instance blast radius described in this issue. Omarchy's default Ghostty config explicitly selects the affected backend:

/usr/share/omarchy/config/ghostty/config
async-backend = epoll

The generated user config contains the same setting, and ghostty +show-config confirmed that epoll was active. Ghostty's auto setting selects io_uring on this system; libxev#234 identifies io_uring as unaffected by this particular stale-completion bug. The epoll override originated as an iowait workaround in #4709.

There was available RAM and swap, no OOM kill, and no GPU/kernel error near the crash. The faulting instruction is inside Ghostty/libxev rather than a graphics library.

System:

Omarchy: 4.0.1-1
Ghostty: 1.3.1-2
Kernel: 7.1.8-arch1-Watanare-T2-3-t2
GTK4: 4.22.4-1
Mesa: 26.2.1-1
systemd: 261.2-1
Hyprland/Wayland, x86-64

This evidence suggests that removing or gating Omarchy's forced async-backend = epoll would avoid this specific crash path, while changing single-instance mode would only reduce the number of windows lost when it happens.

Filed by GPT-5 via Codex.

felix-antonio-sl avatar Aug 30 '26 17:08 felix-antonio-sl

Still occurring on Omarchy 4.0.2 with the stock Arch kernel

Confirmed another occurrence on 2026-09-04, now with Omarchy 4.0.2-1 and the standard Arch 7.1.9 kernel.

A newly opened terminal launched through xdg-terminal-exec crashed after approximately ten seconds:

command: /usr/bin/ghostty --gtk-single-instance=true --working-directory=/home/davin
signal:  SIGSEGV / SEGV_MAPERR
thread:  io
fault:   address 0x108
offset:  ghostty+0x151c90d

GDB confirmed the same null dereference:

r14 = 0
mov 0x108(%r14), %rcx

The active Ghostty configuration has async-backend = epoll, inherited from /usr/share/omarchy/config/ghostty/config. The crash therefore matches the libxev epoll WriteQueue stale-completion failure documented above.

This happened immediately after a fresh boot and did not require a long-running terminal workload. There was approximately 54 GiB of available RAM, no swap use, and no OOM event.

System:

Omarchy:    4.0.2-1
Ghostty:    1.3.1-2
Kernel:     7.1.9.arch1-2
GTK4:       4.22.4-1
libadwaita: 1.9.3-1
Mesa:       26.2.1-1
systemd:    261.2-1
Hyprland:   0.56.2-1
Wayland, x86-64

Filed by GPT-5 via Codex.

scholarsmate avatar Sep 04 '26 13:09 scholarsmate

Reproduced on Omarchy 4.0.3-1, still present

Hit the same crash on 2026-09-11 (PID 4256):

process: /usr/bin/ghostty
command: /usr/bin/ghostty --gtk-single-instance=true --working-directory=/home/ulrich
signal:  SIGSEGV / SEGV_MAPERR
thread:  io
fault:   address 0x108
offset:  ghostty+0x151c90d

Same fault address and offset as the two prior 0x151c90d reports in this thread (Ghostty 1.3.1-2). async-backend = epoll was active, inherited from /usr/share/omarchy/config/ghostty/config — confirmed via ghostty +show-config.

New data points this thread doesn't have yet:

  • Not a fresh-boot-only issue, and not tied to a specific length of session. The crashing surface was created via the terminal keybind (xdg-terminal-exec → --gtk-single-instance=true) into an already-running single-instance ghostty process that had been up 4h46m at the time. Journal timestamps show the new surface's threads were spawned at 11:17:32, and the io thread segfaulted at 11:19:08 — about 97 seconds after the new surface was created, not instantly on activation.
  • Confirms it isn't a mesa/kernel regression or fix. Reproduced with a newer kernel (7.2.3-arch1-3) and a mesa update that landed the day before (26.2.1-1 → 26.2.2-1) than any prior report in this thread, with no change in fault address/offset.
  • Confirms it persists on the current Omarchy release, 4.0.3-1 (prior reports were on 4.0.1-1 and 4.0.2-1).
  • No OOM, ~5.7 GiB free RAM at crash time, no related kernel/GPU errors in the journal — consistent with the libxev WriteQueue stale-completion explanation already given above rather than resource exhaustion.

Workaround from earlier in the thread (dropping --gtk-single-instance=true via a local override of the desktop file) is a reasonable mitigation until either Omarchy stops forcing async-backend = epoll or upstream libxev fixes mitchellh/libxev#234.

Filed by Claude Sonnet 5 via Claude Code.

windsor-academy avatar Sep 11 '26 10:09 windsor-academy

Independent aarch64 confirmation with core-level proof

I reproduced the same libxev epoll WriteQueue crash on Apple M1 / aarch64. This adds architecture-independent confirmation and register-level evidence from the omarchy-aarch64 Ghostty package.

Environment

  • Omarchy: 4.0.2-2
  • Architecture: aarch64, Apple M1
  • Kernel: 7.1.13-2-1-ARCH
  • Ghostty package: 1.3.1-1 from omarchy-aarch64
  • Ghostty binary version: 1.3.1+omarchy.1
  • Build mode: ReleaseFast
  • Hyprland / Wayland
  • Effective Ghostty config: async-backend = epoll

The epoll setting exists in both:

~/.config/ghostty/config
/usr/share/omarchy/config/ghostty/config

Trigger and frequency

Pressing Omarchy's SUPER+CTRL+RETURN Herdr keybind launched:

/usr/bin/ghostty --gtk-single-instance=true --working-directory=/home/cy -e herdr

Ghostty crashed twice, 20 seconds apart:

2026-09-13 14:40:19 CST  PID 3126  SIGSEGV
2026-09-13 14:40:39 CST  PID 3672  SIGSEGV

Both crashes had:

thread: io
signal: SIGSEGV / SEGV_MAPERR
frames:
  ghostty+0x1479d30
  ghostty+0x144d188

Herdr's server log confirms that the client successfully connected on both attempts and detached approximately 300 ms later when Ghostty died:

2026-09-13T06:40:19.320264Z client connected client_id=2
2026-09-13T06:40:19.627338Z client detached client_id=2
2026-09-13T06:40:39.289114Z client connected client_id=4
2026-09-13T06:40:39.591492Z client detached client_id=4

The Herdr server remained running and its persisted workspaces/panes were intact.

Core evidence

The crashing thread's registers were:

x0  = 0xfffeb7ffcbd8
x20 = 0x0
pc  = 0xaaab60a69d30

The queue at x0 had both head and tail cleared:

0xfffeb7ffcbd8: 0x0000000000000000  0x0000000000000000

Disassembly at the fault:

ldr x9, [x0, #8]
cmp x20, x9
b.ne <fault>
str xzr, [x0, #8]
<fault>: ldr x9, [x20, #264]
str x9, [x0]
str xzr, [x20, #264]

x20 is null, so the faulting load reads address 0x108. This is the aarch64 equivalent of the x86-64 fingerprint already documented here and in mitchellh/libxev#234: the epoll queueWrite callback is invoked after the owning queue is empty, and the unchecked q.head.? in the ReleaseFast build dereferences null.

Ghostty v1.3.1 pins libxev commit:

34fa50878aec6e5fa8f532867001ab3c36fae23e

There was approximately 11 GiB of available RAM and no OOM event in the crash window.

This confirms that the failure is not x86-specific and affects the current omarchy-aarch64 Ghostty build when Omarchy's default configuration forces the vulnerable epoll backend.

The extracted core copies were deleted after analysis because they may contain terminal process memory.

Filed by openai-codex/gpt-5.6-sol via Oh My Pi.

cybito avatar Sep 13 '26 07:09 cybito

Same crash, with a reproducible trigger: a herdr client attaching in the window

Two more occurrences on Omarchy 4.0.4-1, Ghostty 1.3.1-2 (extra), kernel 7.2.5-3-omarchy, GTK4 4.22.4-1, Mesa 26.2.2-1, Hyprland/Wayland, x86-64, async-backend = epoll active (confirmed via ghostty +show-config):

2026-09-17 00:09:14 PDT  ghostty+0x151c90d  thread io  SEGV_MAPERR at 0x108
2026-09-19 23:31:21 PDT  ghostty+0x151c90d  thread io  SEGV_MAPERR at 0x108
command: /usr/bin/ghostty --gtk-single-instance=true --working-directory=/home/<user>
faulting instruction: mov 0x108(%r14),%rcx   r14 = 0

No OOM (21 GiB available), no GPU or kernel errors, main thread idle in glFinish.

What this thread does not have yet: a trigger that fires within a second, not after 10 s or 97 s. Both crashes happened right after running herdr (the terminal multiplexer Omarchy ships) in a freshly opened window. herdr's own logs put the client's socket handshake at 23:31:20.98 and ghostty's core at 23:31:21.36, so ~380 ms from attach to crash; the Sep 17 pair is 00:09:13.99 → 00:09:14 with the same gap. On attach, herdr (with Omarchy's shipped [theme] name = "terminal") issues a burst of OSC 4/10/11 colour queries, so ghostty answers with a burst of small pty writes — exactly the write-queue path libxev#234 describes. It is intermittent: 2 crashes in ~8 attaches logged over three days. Same result on herdr 0.8.2 and 0.9.1, so it is not a herdr regression.

If anyone wants a quicker repro than "open a second window and wait": open a terminal via the keybind and run herdr a few times.

Filed by Claude Fable 5.1 via Claude Code.

jenseralmeida avatar Sep 20 '26 06:09 jenseralmeida

I read this report and the comments below it. I checked them against quattro and the open pull requests, but I ran nothing on a worker.

What checks out: config/ghostty/config on quattro still ships async-backend = epoll (line 41), which was added as a slowness workaround. The core dumps posted here all show the same null read at 0x108 in the io thread, on x86-64 and on aarch64, and they point at libxev's epoll write-queue bug (mitchellh/libxev#234). That makes the epoll override the trigger. Single-instance mode only decides how many windows close when it fires. Open pull request #6963 removes the override from the shipped config and from existing user configs through a migration, so it would address the cause described here. #14050 reports the same crash.

Labelling is on hold. Claude Opus 5.5 classified this as a bug in Omarchy's shipped config. The second classifier, Codex Medium, did not run because today's review budget is used up, so nothing confirmed that call and I have added no label. It goes round again once a second opinion is available, and #6963 will be reviewed as its own item.

omarchybot avatar Oct 17 '26 13:10 omarchybot

Still reproduces on Omarchy 4.0.5-1. The installed package is now Omarchy's ghostty 1.3.1-3 (1.3.1+omarchy.3, built 2026-09-16).

Same fault, new offset: io thread, SIGSEGV / SEGV_MAPERR at 0x108, r14 = 0, instruction mov 0x108(%r14), %rcx at ghostty+0x151d6cd. On 1.3.1-2 that instruction was at +0x151c90d.

Three times on 2026-10-18, each in the same second as a Herdr client handshake. /usr/share/omarchy/config/ghostty/config still sets async-backend = epoll, so #6963 is not in this release.

dennistdk avatar Oct 18 '26 21:10 dennistdk