omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

omarchy-crash-watch stops sending crash notifications after an in-place upgrade (logs `Unknown option:`)

Open Dandroid-D opened this issue 3 months ago • 3 comments

System details

Omarchy 4.0.1-1 (upgraded in place from 4.0.0-1), Arch Linux, bash 5.3.15(1)-release, systemd 261.2-1, quickshell 0.3.1.

(omarchy-debug wants sudo and a TTY, so I could not capture it non-interactively — the equivalent facts are inline below.)

What's wrong?

After the 4.0.0-1 → 4.0.1-1 upgrade, crashes stopped raising a notification. The failure is not silent — omarchy-crash-watch logs it:

Aug 26 23:02:30 <host> omarchy-crash-watch[196120]: Unknown option: Process crashed: zcode
Aug 26 23:13:15 <host> omarchy-crash-watch[205358]: Unknown option: Process crashed: zcode

Observed crash count is n=2 (both zcode). I'm not claiming every crash in the window failed — only that every crash I observed did. The state persists until the service is restarted or the user logs out. Restart=always doesn't help: the daemon never exits, so systemd never restarts it.

Root cause

In 4.0.1-1, --exec must come last, because it consumes the rest of the line as the click command's argv (omarchy-notification-send:118-119; omarchy-crash-watch:39 states the same contract in a comment). It is still an option, not a positional — it's listed among the known flags at omarchy-notification-send:106.

A running omarchy-crash-watch isn't restarted by the package transaction, so it keeps executing the pre-upgrade script body: bash holds the script on fd 255 for a non-interactive run and reads it lazily, so when pacman replaces the file the running shell keeps reading the unlinked inode (/proc/<pid>/fd/255 -> /usr/bin/omarchy-crash-watch (deleted)). The old caller then invokes the new omarchy-notification-send from disk with the old argv shape, which is rejected at omarchy-notification-send:133.

Recovering the pre-upgrade argv shape

The 4.0.0-1 script body is no longer on disk or in the pacman cache. Its argv shape is still recoverable by construction, because the new parser is deterministic and the rejected token was logged. A caller that passes --exec <single command string> before the headline reproduces the journal line exactly, on a current 4.0.1-1 system:

$ omarchy-notification-send --urgency critical \
    --exec "omarchy-agent-crash 1234 zcode /usr/bin/zcode SIGSEGV" \
    "Process crashed: zcode" "Click to diagnose with AI"
Unknown option: Process crashed: zcode
Usage: omarchy-notification-send [--app-name <app-name>] [-g <glyph>] [-u <low|normal|critical>] [-i <icon>] [-t <ms>] [-r <id>] [-p] [--image <path-or-uri>] <headline> [description] [--exec <program> [args...]]
$ echo $?
1

Both lines match the journal byte for byte. The new parser takes --exec as the headline, the command string as the description, then meets Process crashed: zcode in option position — the only argv shape that puts that token there. So 4.0.0-1 passed --exec a single command string ahead of the headline; 4.0.1-1 requires it last and space-separated.

Reproduction (works on a current system; no 4.0.0-1 package needed)

  1. omarchy-notification-send --urgency critical --exec "some-cmd arg" "Process crashed: x" "body"
  2. Expected: a notification. Actual: Unknown option: Process crashed: x, exit 1.

Evidence

  • omarchy upgraded 4.0.0-1 → 4.0.1-1 at 2026-08-26 23:02:11 (/var/log/pacman.log).
  • Unit file — Restart=always, no RestartTriggers:
    [Service]
    Type=simple
    ExecStart=/usr/bin/omarchy-crash-watch
    Restart=always
    RestartSec=5
    
  • omarchy does ship libalpm hooks — pacman -Ql omarchy lists 00-omarchy-update-guard.hook, 10-omarchy-hyprland-reload-pause.hook, 90-omarchy-hyprland-reload-resume.hook. None restarts a user service. I mention this because it means the packaging mechanism for the fix below already exists and is already used.
  • After restarting the service, an induced SIGSEGV produced a delivered notification (the notification server's returned id advanced beyond the test's own probes, and a traced run shows announce → omarchy-notification-wait → omarchy-notification-send … --exec … completing). New caller and new callee agree; the failure is confined to the version-skew window.
  • Unknown: the byte content of 4.0.0-1's two scripts.

Suggested fix

RestartTriggers= in the unit isn't sufficient here. It restarts a unit when a listed file changes as seen by systemd, but these are user units: the package transaction runs as root outside any user manager, so each running systemd --user instance would have to notice and act per session. A PostTransaction libalpm hook is the layer that actually observes the transaction — the same mechanism the package already uses for the Hyprland reload pause/resume pair. Restart omarchy-crash-watch.service for each active session on Target = omarchy. Alternatively, negotiate the --exec argv shape rather than assuming caller and callee upgrade in lockstep.

Related, not duplicates

  • #8346 — clicking the toast no-ops via the omarchy-exec-argv hint. That's the click path after a toast exists; this issue is the toast never being sent.
  • #7155 — replaces journalctl -f with inotify on the coredump dir. Orthogonal to the argv skew, but it would also remove a separate failure mode I hit on this machine: a watcher instance up ~9.5h announced none of two induced SIGSEGV crashes while systemctl reported it active and nothing was logged; its journalctl -f child was attached to the correct live journal (fd inode matched, no rotation), and script logic, environment and the notification path all tested good in isolation. A restart fixed it. I have not root-caused that one and am not claiming it here — but a watcher that doesn't follow the journal can't hit it.

Filed by Claude (Opus 5) via Claude Code.

Dandroid-D avatar Aug 27 '26 15:08 Dandroid-D

Proposed fix: systemctl --user try-restart omarchy-crash-watch.service from omarchy-update-restart (same place the shell is already restarted after an update). try-restart is a no-op if the watcher is stopped, so crash-capture-off stays off. A one-shot migration would not cover the next script change.

Will open a small PR against quattro.

Elshayib avatar Aug 28 '26 02:08 Elshayib

I can reproduce the caller/sender mismatch using the tagged v4.0.0 and v4.0.2 scripts. This also matches a historical failure after an in-place 4.0.0-1 to 4.0.2-1 upgrade on Arch Linux.

In v4.0.0, announce() passes --exec "$exec_command" before the headline. In v4.0.2 it passes the headline and description first, then --exec omarchy-agent-crash ... as separate arguments.

I tested the actual announce() function from each tagged watcher against the v4.0.2 sender. The notification wait helper returned success and busctl was stubbed, so the test did not display a notification or induce a crash.

Caller Sender Result
v4.0.0 v4.0.2 Exit 1, Unknown option: Process crashed: example
v4.0.2 v4.0.2 Exit 0

The local package upgrade occurred September 4 at 01:32:14 UTC+03. A retained journal error at 05:53:24 that day names Brave. The watcher had started before the upgrade. That same boot continued through September 10. Its journal contains 29 matching parser errors: one on September 4, four on September 9 and 24 on September 10, across multiple applications. After the September 11 reboot, the current script pair passes the same argument-shape check and no matching notification parser error was observed in the inspected current-boot interval. These counts describe recorded failed invocations, not every notification attempted.

The old process is no longer available, so the test proves the tagged-version incompatibility rather than recovering its exact former in-memory script. It supports restarting an active watcher after an update, while keeping an intentionally stopped watcher stopped.

Sources: v4.0.0 watcher, v4.0.2 watcher, v4.0.2 sender.

code5717 avatar Sep 11 '26 20:09 code5717

Checked against current quattro (c352b62d6): the mismatch is real and not fixed there yet. v4.0.0:bin/omarchy-crash-watch passes --exec "<command string>" before the headline. Since bf2013e6f, bin/omarchy-notification-send takes everything after --exec as the click command, so the old call shape is rejected at line 133 with exactly the Unknown option: Process crashed: … line in your journal. Nothing on quattro restarts a watcher that is already running. Restart=always only fires when the process exits, and the crash-watch migration runs start, which does nothing to an active unit.

One refinement to the diagnosis: lazy reading from fd 255 isn't needed to explain it. Bash parsed announce() and the main loop when the watcher started, so the old call shape stays in memory however the file on disk changes. Only the sender is picked up fresh.

#8708 fixes this. It adds systemctl --user try-restart omarchy-crash-watch.service to the services phase of omarchy-update-restart, which runs as the user right after the package transaction, and does nothing if the watcher is stopped. That pull request already says it closes this issue, and it is being reviewed and verified on a worker as its own item. It does not cover upgrades that skip omarchy-update (a raw pacman -Syu through the guard's bypass). That's outside the normal update path, so it isn't treated as a gap in the fix.

I reviewed this by reading the source and did not reproduce it on a worker, since the fix lives in #8708. Codex Medium gave a second opinion: it agreed on the mechanism and on #8708. It also ran v4.0.0's announce() against the current sender, got the same error, and added the fd-255 point above. Independence is not guaranteed, because it reviewed after my reading. This issue now waits on the maintainer's decision on #8708.

omarchybot avatar Oct 09 '26 04:10 omarchybot