omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Apps started from the Super+Space menu inherit RLIMIT_RTTIME=0 (PipeWire + portal without rtkit) and are SIGKILLed once they get a real-time thread; since 4.0.4 this kills SteamVR

Open kh4rit-bot opened this issue 2 months ago • 10 comments

System details

Lenovo Legion Pro 5 16ARX8, Ryzen 7 7745HX, RTX 4060 Laptop, Omarchy 4.0.4, linux-omarchy 7.2.5-3, PipeWire 1.6.8, quickshell 0.3.1

What's wrong?

Everything launched from the Omarchy menu runs with a hard real-time CPU limit of zero:

$ prlimit --pid $(pgrep -x quickshell) --rttime
RTTIME  timeout for real-time tasks  0  0  microsecs

The kernel kills a process with that limit (SIGKILL, no core dump, nothing in the journal) as soon as one of its threads runs SCHED_FIFO/RR. Since 4.0.4 that happens to SteamVR: on linux-omarchy its compositor is granted real-time threads, so with Steam started from the menu SteamVR fails with "SteamVR Fail (-203)" every time, about 10 ms after the compositor starts. Steam started from a terminal works. On the Arch kernel the real-time request was refused, which hid the problem.

Where the zero comes from. It is not something the shell does on purpose, it happens in every PipeWire client:

$ PIPEWIRE_DEBUG=mod.rt:5 pw-mon
mod.rt | failed to set realtime policy: Operation not permitted
mod.rt | initialized using RTKit
mod.rt | clamping rt.time.soft from 18446744073709551615 to 0 because of RTKit
mod.rt | set_rlimit() rt.time.soft:0 rt.time.hard:0

rtkit is not installed, so module-rt ends up at xdg-desktop-portal's Realtime interface, which reports RTTimeUSecMax=0, and module-rt applies that zero to its own process. quickshell is a PipeWire client and also the launcher, so its children inherit it. Apps started from a Hyprland keybinding or a terminal don't. 31 of 128 processes in my session carried the zero.

To reproduce

  1. Start any app from the menu, then grep realtime /proc/<pid>/limits. Compare with the same app started from a terminal.
  2. For the kill: prlimit --rttime=0:0 steam, start SteamVR. The compositor's log stops right after it sets its thread priority, vrserver reports it exited, SteamVR shows -203. Same with Steam started from the menu. (If a umu/Proton session such as Battle.net is already running, SteamVR starts its compositor inside that session's container instead, where real-time scheduling is refused, and it survives.)

What I tested as a fix

  • pacman -S rtkit plus systemctl --user restart xdg-desktop-portal: the portal then reports RTTimeUSecMax=200000, and a new PipeWire client gets a 200000/200000 limit instead of 0/0, which is what other distros run with. Processes that already have the hard zero (quickshell) keep it until they are restarted.
  • rtportal.enabled = false in the module-rt args of client.conf also keeps the limit unlimited.
  • Not verified: SteamVR started from the menu with the 200 ms limit. On my machine a running umu session (Battle.net) takes over SteamVR's compositor launch, so I could not get a clean run.

Without rtkit, PipeWire's own data-loop threads also run SCHED_OTHER here.

Related: #9390 reports the missing rtkit from the audio side, and #12428 installs it. That would fix this too, with one addition: the portal and the shell have to be restarted as well, see my comment there. Possibly the same cause: #11862.

kh4rit-bot avatar Sep 18 '26 18:09 kh4rit-bot

Another case, and a wider trigger than real-time threads: with the inherited RLIMIT_RTTIME of 0/0, a thread does not need to be SCHED_FIFO/RR to be killed. The kernel also checks RLIMIT_RTTIME whenever a per-thread CPU-time timer fires, and with a hard limit of 0 that check sends SIGKILL straight away. Any process that arms a thread CPU timer dies.

How it showed up here: an app launched from the Super+Space menu, and everything it starts (a Playwright test suite and its headless Chromium) inherits 0/0. The suite lost random tests to "Target crashed" and workers exiting with SIGKILL. A signal:signal_generate trace caught the kill: sig=9 code=128 grp=1, sent by the renderer's own Chrome_ChildIOThread to itself, with nothing in the journal.

Minimal repro, no real-time scheduling involved:

import ctypes, resource, time
print(resource.getrlimit(resource.RLIMIT_RTTIME), flush=True)
libc = ctypes.CDLL(None)
class ts(ctypes.Structure): _fields_ = [('s', ctypes.c_long), ('ns', ctypes.c_long)]
class its(ctypes.Structure): _fields_ = [('interval', ts), ('value', ts)]
import signal; signal.signal(signal.SIGALRM, lambda *a: None)
t = ctypes.c_void_p(); libc.timer_create(3, None, ctypes.byref(t))  # CLOCK_THREAD_CPUTIME_ID
libc.timer_settime(t, 0, ctypes.byref(its(ts(0, 10**8), ts(0, 10**8))), None)
end = time.time() + 2
while time.time() < end: pass
print('survived')

From a menu-launched app it prints (0, 0) and is killed (exit 137). Under systemd-run --user --wait --pipe python3 probe.py it prints (-1, -1) and survives. Two full Playwright suites run at once through systemd-run --user, the load that crashed them before, both passed with no Chromium kills in the trace.

linux-omarchy 7.2.5-3, PipeWire 1.6.8, xdg-desktop-portal 1.22.1, rtkit not installed.

zaingulel avatar Sep 30 '26 20:09 zaingulel

Confirmed the rtkit fix end to end here: after pacman -S rtkit and a reboot, menu-launched apps get RLIMIT_RTTIME 200000/200000, the repro above survives, and two full Playwright suites run at once, with no workaround, pass with no crashes.

zaingulel avatar Sep 30 '26 21:09 zaingulel

Confirming on a desktop (Omarchy 4.0.4-1, linux-omarchy 7.2.5-3, PipeWire 1.6.8, xdg-desktop-portal 1.22.1, no rtkit), with a different victim: Claude Desktop (claude-desktop package, Electron 44 / Chromium 152). Chromium loads libpipewire in its main process, so the browser process itself ends up with RLIMIT_RTTIME 0/0 and every zygote-forked child inherits it. Over one evening the kernel SIGKILLed its window renderer 11 times, its GPU process 8 times, its network and audio services once each, and the whole app three times. The app only logs render process gone: killed, exitCode 9; no core dump. tracepoint:signal:signal_generate shows sig=9 code=128 sent from the victim's own thread (Compositor, DedicatedWorker, PerfettoTrace), i.e. the RLIMIT_RTTIME check firing for a non-real-time thread with a CPU-time timer armed, the same mechanism zaingulel described. Brave on the same machine is unaffected because it never loads libpipewire.

Two details that may help others: (1) after pacman -S rtkit no reboot is needed; systemctl --user restart xdg-desktop-portal is enough, because the portal reads rtkit's properties only at its own startup. Before the restart it kept advertising RTTimeUSecMax=0 even with rtkit-daemon running; after it, 200000, and a fresh pw-mon got RLIMIT_RTTIME 200000/200000. (2) A user-level workaround that also works (tested via PIPEWIRE_CONFIG_DIR): ~/.config/pipewire/client.conf.d/*.conf with context.properties = { module.rt = false }.

galaczi avatar Oct 10 '26 23:10 galaczi

Checked against current quattro: this is still a real bug there. rtkit is in neither package list, and the only realtime change that has landed (#12958) covers the speaker-tuning host alone, so every other PipeWire client still takes the portal's zero budget as a hard RLIMIT_RTTIME and passes it to whatever it launches.

The fix is #12428, which is open against quattro and already marked as closing this issue. It adds rtkit to install/omarchy-base.packages for fresh installs. For existing installs, its migration installs rtkit and then restarts xdg-desktop-portal before the audio units, so the portal reports 200000 rather than 0 by the time PipeWire clients reconnect. That is the restart @kh4rit-bot and @galaczi measured as necessary. A process that already carries the hard zero cannot raise it. omarchy update ends by restarting the shell through Hyprland, which gives the launcher a clean limit, but any app started from the menu before the update keeps 0/0 until it is relaunched.

Nothing was run for this issue: the reproduction and the migration were exercised on a worker when #12428 was reviewed, and that pull request is worked as its own item. Claude Opus 5.5 read the report and the landed source. Codex Medium reviewed the same independently and agreed on both points. It also traced the kernel's check to show that a thread CPU-time timer under a hard zero is enough to trigger the kill without any real-time scheduling, which accounts for the Chromium, Electron and Playwright cases. Its independence is not guaranteed. One thing remains unconfirmed: nobody has yet run SteamVR from the menu with the 200 ms budget.

This is waiting on the maintainer's decision on #12428. Nothing is needed from the reporters.

omarchybot avatar Oct 12 '26 07:10 omarchybot

Still real on quattro. Fix is #12428 (install rtkit). #12958 only covered the speaker-tuning host. Track #12428.

jandrusk avatar Oct 12 '26 18:10 jandrusk

I can confirm this affects Chrome and ChatGPT/Codex Desktop too.

After switching from Stable to Edge, I experienced unexpected Chrome exits, ChatGPT backend restarts, and brief window redraws. On 7.2.8-5-omarchy-bore, kernel tracing captured SIGKILL with code=128 through posix_cpu_timers_work, including a tokio-rt-worker event matching a Codex backend termination.

Local checks confirmed:

  • rtkit was not installed.
  • The portal advertised RTTimeUSecMax=0.
  • Chrome, ChatGPT, and the Codex backend had RLIMIT_RTTIME=0/0.

After booting stock Linux 7.2.9-arch1-1, a disposable process using a thread CPU timer reproduced the failure with RLIMIT_RTTIME=0/0 (terminated by SIGKILL). The same test survived with 200000/200000. This reproduces the mechanism on stock Linux as well; it does not establish a BORE-specific defect.

Installing rtkit 0.14-1, restarting xdg-desktop-portal, and refreshing the audio services and Omarchy shell changed the portal budget and fresh PipeWire client limits to 200000/200000. I then rebooted to clear the inherited zero limits from existing apps.

Post-reboot checks confirmed the corrected limits on Chrome, ChatGPT, Codex, Quickshell, PipeWire, and WirePlumber. The system has been stable during use since then, with no further observed unexpected exits or backend restarts. Longer-term observation is still ongoing.

Currently testing on stock Linux; BORE has not yet been retested after the fix.

markey avatar Oct 14 '26 20:10 markey

One addition for the migration in #12428: apps that already carry the hard zero don't need a relaunch, because root can raise the limit in place. An unprivileged process can't raise its own hard limit, but prlimit(2) with CAP_SYS_RESOURCE can change it for a running process.

Tested here on Omarchy 4.0.5-1, linux-omarchy 7.2.8-9, PipeWire 1.6.9, xdg-desktop-portal 1.22.1. ChatGPT Desktop was opened from the menu, got RLIMIT_RTTIME 0/0, and was SIGKILLed (sig=9 code=128, sent by itself).

  1. pacman -S rtkit, then systemctl --user restart xdg-desktop-portal (portal: 0 → 200000), then omarchy restart shell (new Quickshell: 200000/200000).
  2. 17 processes still had 0/0 from earlier launches: terminals opened from the menu and everything running inside them, mpv, the clipboard wl-paste watchers. As root:
    for d in /proc/[0-9]*; do
      awk '/Max realtime timeout/{exit ($4=="0")?0:1}' "$d/limits" 2>/dev/null &&
        prlimit --pid "${d#/proc/}" --rttime=unlimited:unlimited
    done
    
    All 17 changed in place and kept running, and none was left at 0.

The migration already runs with sudo, so it could end with this loop. Then nothing started from the menu before the update keeps 0/0 until it is relaunched or the machine reboots. Terminals matter most here: anything running inside a menu-launched terminal, such as long-lived CLI tools or agents, inherits the limit too.

Filed by Claude Opus 5.5 via Claude Code.

Alront avatar Oct 20 '26 23:10 Alront

Another confirmation, with more victims. Omarchy dev (3ac43659dcb), linux-omarchy 7.2.8-9, PipeWire 1.6.9, xdg-desktop-portal 1.22.1, rtkit not installed.

Apps launched from the menu were killed at random over a week, with no core dump, no OOM, and no sender in the audit log for kill/tkill/tgkill/pidfd_send_signal:

  • Google Chrome Dev: the main process exited with rc=137, several times
  • JetBrains Rider: the frontend (JVM) exited with rc=137 twice; idea.log just stops
  • VS Code: the whole app closed. A signal:signal_generate trace caught this one: SIG9 from the kernel via posix_cpu_timers_work
  • xfreerdp: closed with no signal recorded, in the same window as the Rider and Chrome Dev deaths

At the time, quickshell and every app started from the launcher had Max realtime timeout 0 0.

After pacman -S rtkit, restarting omarchy-shell and relaunching the apps, everything gets 200000/200000. In the two days since, the tracer logged no posix_cpu_timers_work kills and every logged app exit was rc=0.

Crucialjun avatar Oct 21 '26 10:10 Crucialjun

Re-checked against current quattro. Nothing has changed for x86_64. #14820 added rtkit to install/omarchy-aarch64.packages, and migration 1790984500 installs it, but only on the N1x: omarchy-pkg-defaults leaves the aarch64 list out on x86_64, and the migration exits unless omarchy-hw-aarch64-n1x matches. The fix is still #12428, which is open and closes this issue.

On @Alront's suggestion: root can raise a running process's hard limit in place with prlimit. The kernel allows it with CAP_SYS_RESOURCE, so the statement in the earlier reply that a process with the hard zero cannot be fixed without a relaunch was too strong. Only the process itself is unable to raise it. The value matters, though. unlimited is not the limit rtkit expects. verify_process_rttime() in rtkit-daemon.c reads the hard Max realtime timeout from /proc/<pid>/limits and refuses realtime scheduling unless it parses as a number no greater than rtkit's maximum (200000 µs by default). A process raised to unlimited would therefore be refused realtime by rtkit on any later request. A repair that writes --rttime=200000:200000, which is the limit a fresh PipeWire client gets once rtkit is running, gives those processes the same state as one launched after the fix. Either way, a sweep over every process as root also touches other users' processes and system services that may have a zero limit set on purpose. Whether to add this to #12428's migration, and how widely it should reach, is for #12428's author and the maintainer to decide.

Nothing was run for this issue: the reproduction and the migration were exercised on a worker when #12428 was reviewed, and that pull request is worked as its own item. Claude Opus 5.5 read the new comments and the current source. Codex Medium reviewed both independently and agreed that the x86_64 verdict holds. It also raised the rtkit check on the unlimited value, and Claude confirmed that check in rtkit's source. Its independence is not guaranteed.

This is waiting on the maintainer's decision on #12428. Nothing more is needed from the reporters. Thank you for the further confirmations.

omarchybot avatar Oct 21 '26 17:10 omarchybot

Your fix path is confirmed on another machine (Omarchy 4.0.6-1, kernel 7.2.8-9-omarchy, pipewire 1.6.9-1, xdg-desktop-portal 1.22.1-2, rtkit not installed):

  • pacman -S rtkit → the system bus answers org.freedesktop.RealtimeKit1 RTTimeUSecMax = 200000 right away (the package's post-transaction hook reloads the system bus configuration, so the new activation file is picked up without a reboot or a manual dbus-broker restart; the unit is rtkit-daemon.service, D-Bus activated).
  • The portal, however, keeps reporting 0 until it is restarted: systemctl --user restart xdg-desktop-portal.service → then it reports 200000 as well. So the portal restart is a hard requirement, not a nicety.
  • The module-rt log lines from your report match the current upstream source exactly — src/modules/module-rt.c, rtkit_finish_init() (master b58c71296e8f) clamps both members of the limit to the budget and then calls setrlimit():
	impl->rl.rlim_cur = SPA_MIN(impl->rl.rlim_cur, rttime_max);
	impl->rl.rlim_max = SPA_MIN(impl->rl.rlim_max, rttime_max);
	set_rlimit(&impl->rl);

With a budget of 0 that installs {0, 0} as RLIMIT_RTTIME. Because the hard limit is 0 as well, the kernel's CPU-timer path (check_thread_timers → check_rlimit) sends SIGKILL — which is why the symptom is a kill without any realtime scheduling being involved.

Two additions that are useful for your in-place rescue advice:

The limit is per thread group. Writing RLIMIT_RTTIME through any thread of a process changes it for all of its threads; reading it through any thread returns the group value (measured directly). So one prlimit per process is enough — your "on each of its processes (the zygotes too)" is exactly right, because each zygote is its own process/group. On the machine above this raised the limit of 1678 threads in 144 processes in place, with every application left open and no shell restart:

sudo -v
for pid in $(pgrep -u "$USER" -f .); do
  sudo -n prlimit --pid "$pid" --rttime=unlimited:unlimited 2>/dev/null
done

(needs root — the owner cannot raise a hard limit of 0; per-process, so the zygotes are covered as well).

The shell keeps the zero until it is restarted. The shell is a PipeWire client, so it holds RLIMIT_RTTIME 0/0 itself and hands it to everything it launches — measured here: 35 of 35 threads of the shell carried the zero, and 1678 of 2178 threads of the whole user session did. omarchy-restart-shell therefore remains necessary for a running session unless the limits are raised in place as above.

For the migration angle: installing rtkit without restarting the portal and the shell does not stop the kills on an existing installation, so both belong into the migration that adds the package. The PipeWire-side report about the clamping already exists and is tracked here: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/5429

Shadows-In-The-Space avatar Oct 27 '26 14:10 Shadows-In-The-Space