Repository navigation
fix(linux): refuse realtime audio scheduling under an inherited zero RLIMIT_RTTIME - #36183
Conversation
|
Crash scan 63 (v1.4.245, 9 Omarchy SIGKILL reports from 6 users, GPU process usually killed first): the "unidentified trigger on RTPRIO=0 machines" is most likely kernel RCU priority boosting (Omarchy kernels:
This PR is still correct, but it only covers part of the problem. The only Orca-side fix for the whole class would be a Linux startup self-relaunch as a |
6494f34 to
2a0388d
Compare
…orts Omarchy launches apps from a shell that holds a hard RLIMIT_RTTIME of 0 (no rtkit, so the portal's zero realtime budget is applied by PipeWire module-rt). Orca inherits it in every process, and the kernel CPU-timer watchdog SIGKILLs GPU and renderer processes with no dump while GBs of memory are free. A hard limit cannot be raised without privilege, so record it as a startup breadcrumb and in process-gone crash details. Move the daemon's /proc/self/limits parser into one shared reader so the terminal warning and crash attribution flag the same zero soft or hard limit.
…and restore timer-armed wording
…_RTTIME Chromium makes audio threads SCHED_RR whenever RLIMIT_RTPRIO allows. Under a zero hard RLIMIT_RTTIME (Omarchy launcher without rtkit) the kernel's RT watchdog SIGKILLs that renderer or audio process on its first tick, so any sound (custom notification sound, browser media, video) killed the renderer with exit 9. When RTTIME is 0 and RTPRIO is nonzero, zero RLIMIT_RTPRIO with prlimit for main and its existing zygotes before the first window; Chromium then falls back to a nice value. The linux_rttime_limit breadcrumb records the outcome.
… was shown to fix
Evidence (Electron 43.8.1 linux-arm64, the version Orca ships, in Docker
with --ulimit rtprio=95:95; page plays a WebAudio oscillator; guard step is
the same /proc tree walk + `prlimit --pid <pid> --rtprio=0:0` as this module):
rttime unlimited: AudioOutputDevi / AudioWorkerThre go SCHED_RR prio 8,
renderer survives 6 s
rttime 0:0, no guard: "audio started" -> render-process-gone killed 9 (~80 ms)
rttime 0:0, guard: "guard lowered rtprio on 5 pids", no RR threads,
audio keeps running, renderer survives 6 s
Limits: this is a minimal Electron app, not a packaged Orca build. The only
reachable Omarchy box has RTPRIO 0/0 and RTTIME unlimited, and an
unprivileged user cannot raise RTPRIO there. Under RTPRIO 0/0 the guard
records rtPrio=not-needed and changes nothing, so reported zero-RTTIME
SIGKILLs on such machines (for example the one 2.6 s after load with no
audio breadcrumb) have a different trigger. Treat this as a partial
mitigation plus diagnostics; the crash bucket stays open.
…ess tree can't be fully walked listProcessTree silently skipped unreadable /proc/<pid>/task/<tid>/children files, so on kernels without CONFIG_PROC_CHILDREN the guard lowered only the main process yet recorded rtPrio 'lowered'. Track whether any live thread's children list was unreadable and report 'lowered-partial-tree' in that case. Tests now use a fake /proc root so tree walking is deterministic on any host.
The linux_rttime_limit breadcrumb rotates out of the 30-entry ring long before a late SIGKILL, so stash the guard's outcome and attach it as rlimitRtPrioStartup next to the rlimitRtTime fields. A short-lived child that exits between the /proc walk and its prlimit call no longer turns the outcome into prlimit-failed. Adds direct tests for the rttime/rtprio readers and the new crash-detail fields.
2a0388d to
6e05777
Compare
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 11 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
Description
What users saw (Linux, mostly Omarchy): the Orca window goes blank or reloads. The crash report says
Renderer process gone { reason: 'killed', exitCode: 9 }, meaning the kernel sent SIGKILL. The affected sessions inherit a hardRLIMIT_RTTIMEof0/0from a launcher that runs without rtkit.Root cause (one confirmed path): Chromium moves its realtime-audio threads to
SCHED_RR(priority 8) wheneverRLIMIT_RTPRIOallows it. The affected threads are the renderer'sAudioOutputDevicethread (<audio>,<video>, WebAudio) and the audio-service thread. Chromium has no switch to turn this off. With a hardRLIMIT_RTTIMEof 0, the kernel's RT watchdog findsrttime(0) >= hard(0)on the first tick and SIGKILLs the process. So anything that plays sound kills the renderer within milliseconds: a custom agent-finished notification sound, media in a browser pane, video, or dictation.What this PR changes:
RLIMIT_RTTIMEin Linux SIGKILL reports and adds thelinux_rttime_limitbreadcrumb.src/main/linux-rttime-limit.ts: adds a shared/proc/self/limitsreader andallowsRealtimePriority(), which is true when the soft or hardRLIMIT_RTPRIOis non-zero.src/main/startup/linux-realtime-scheduling-guard.ts(refuseRealtimeSchedulingUnderZeroRtTime):/proc/<pid>/task/*/children. This covers the zygotes, GPU and utility processes; later renderers fork from the zygotes.prlimit --pid <pid> --rtprio=0:0on each process, async throughrunProcess.sched_setschedulerreturns EPERM and Chromium falls back to a nice value.{soft, hard, rtPrio: lowered | lowered-partial-tree | not-needed | prlimit-failed}in the breadcrumb.lowered-partial-treemeans prlimit succeeded but a live thread'schildrenlist could not be read (e.g. a kernel withoutCONFIG_PROC_CHILDREN), so the breadcrumb does not claim zygotes it never saw were lowered.main-process-ready-runtime.ts: awaits the guard at the start ofinitializeReadyRuntimeServices, before any window exists.Scope (please read): this fixes only the
RLIMIT_RTPRIO > 0path. On the Omarchy box we can test, RTPRIO is0/0, and real Orca never went realtime or armed a CPU timer there. Kills on RTPRIO=0 machines (heavy renderer CPU, one renderer killed 2.6 s after load) still have an unidentified trigger, so keep that crash bucket open. The newrtPriobreadcrumb field will show which reporters have RTPRIO above 0. The full fix for affected users is still Omarchy #16824 or installing rtkit.Fix evidence
Rig: omarchy (kernel 7.2.5-3-omarchy, no rtkit).
ORCA_BACKGROUND_LAUNCH=1and an isolated HOME and user-data.nsenter -t 1 -m+setpriv), with the real sandbox on.LD_PRELOADshim logssched_setscheduler,timer_createandsetrlimit.<audio>+ WebAudio x3, then one recorded<video>.1. Mechanism observed in real Orca (host limits, RTPRIO 0): on every playback the browser calls
sched_setscheduler(tid, SCHED_RR=2)on the rendererAudioOutputDevicethread and on the audio-service thread:2. Kernel check (
rr_probe.cin docker):3. Same v1.4.244 binary, before and after (RTPRIO 95/95, RTTIME 0:0). The "after" binary differs only in
out/main/index.js: a faithful JS port of this guard, injected at the same point and awaited, with the asar round-trip checked withcmp.Controls, all 0 kills:
In the last row the guard does nothing (no guard line, RR still succeeds). It changes nothing when RTTIME is not 0.
Earlier runs:
--no-sandbox(A-base/B-mit): 4 kills became 0.prlimitworked across the sandboxed zygote's user namespace (4 pids lowered).Local checks:
pnpm check:changed --maxWorkers=2after rebasing on origin/main: 21 of 22 checks passed (format, lint, typecheck, ratchets including sync-spawn, import boundaries).unit tests, and it fails for a local reason. In this worktree every vitest file fails to load with[TSCONFIG_ERROR] Failed to load tsconfig '@electron-toolkit/tsconfig/tsconfig.node.json', a pnpm global-store link problem. That includes files this PR does not touch (for example theorchestration/federation/*suites), and the investigation worktree on main fails the same way.ELI5
Linux has a rule: "if a thread asks to be a VIP (realtime), it gets a stopwatch, and when the stopwatch runs out it is thrown out." Some Omarchy setups set that stopwatch to zero seconds. Chromium always asks for VIP status for its sound threads. So the moment Orca plays any sound, the stopwatch is already at zero and the kernel kills the window.
This PR checks for that situation at startup. If it finds it, Orca gives up its right to ask for VIP status. Sound threads then run as normal high-priority threads, with no stopwatch, so nothing gets killed.
Trade-offs
RLIMIT_RTTIME0 andRLIMIT_RTPRIOabove 0): Orca's audio threads run at a nice value instead ofSCHED_RR, so audio could glitch under heavy CPU load. Today those threads are killed outright.prlimit: it relies on util-linuxprlimitbeing on PATH. If it is missing, the guard does nothing and recordsrtPrio=prlimit-failed.prlimitspawns before the first window, only on affected machines. Everywhere else the cost is one/proc/self/limitsread.prlimitwindow could keep RTPRIO above 0. This is unlikely because the guard runs before any window.Adversarial review
2 loops, each with a fresh reviewer subagent. Final verdict: clean.
Loop 1, not clean, 1 P1: the reviewer found the code correct:
/procchildren walk reaches the zygotes.prlimitlowering needs no privilege.sched_setschedulerchecks the target thread's RTPRIO.The P1 was that the evidence did not cover the reported bucket: the testable box has RTPRIO 0, and the audio SCHED_RR kill had not been reproduced in real Orca with RTPRIO above 0.
Fixed: the kill was reproduced in real Orca v1.4.244 with RTPRIO 95 and RTTIME 0:0 (SF-base: 4 kills with exit 9). The guarded binary showed 0 kills (SG-mit-ready), and the controls are in the table above. The guard docs and this PR were also rescoped to the RTPRIO > 0 path (commit
docs(linux): scope the realtime guard…), and the bucket stays open for RTPRIO 0 reporters.Loop 2, clean, no P0 or P1: the reviewer checked:
platform_thread_linux.cc(kRealtimeAudio usesSCHED_RR, 8, then falls back to a nice value).runProcess, and that it does nothing off Linux.Notes below the P1 bar: the fork race during the async window; without
CONFIG_PROC_CHILDRENonly main would be lowered (Arch enables it); a setuid sandbox helper could make the breadcrumb sayprlimit-failedeven when the zygote was lowered.