omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

idle.lock above ~24.8 days overflows the QTimer interval negative: ~400 warnings/sec exhausts shmem and crash-loops wayland-wm-app-daemon

Open rnieuwen opened this issue 3 months ago • 5 comments

What happened

A large idle.lock value in ~/.config/omarchy/shell.json overflows the idle service's QTimer interval, producing a runaway Qt warning loop that eventually exhausts shmem/tmpfs and takes the desktop down.

plugins/services/idle/Service.qml:267 binds the interval in milliseconds:

Timer {
  id: lockTimer
  interval: root.lockDelaySeconds * 1000
  repeat: false
  onTriggered: if (root.idleEnabled && root.idledThisCycle) root.lockSystem("lock-timeout")
}

QTimer/QQmlTimer intervals are a signed 32-bit int, so any lockDelaySeconds above 2147483 (~24.8 days) wraps negative. With idle.lock: 2592000 (30 days — a natural way to approximate "never lock"):

lockDelaySeconds = 2592000 - 150 = 2591850
2591850 * 1000   = 2591850000 ms
INT32_MAX        = 2147483647
wraps to         = -1702967296

Qt clamps the negative interval to 1ms and logs a warning on every timer start:

omarchy-shell[1194]: WARN: QBasicTimer::start: negative intervals aren't allowed; the interval will be set to 1ms.

Measured on my machine: ~424 warnings/second, 9,101,214 lines in a single session.

Impact

This is not just log noise. The flood escalates into a system-wide failure:

  1. Journald hits its 4G cap; weeks of real system history are rotated away.
  2. Quickshell's log memfd fills, and shmem/tmpfs allocation starts failing:
    omarchy-shell: ERROR quickshell.logging: Failed to copy log from memfd with error code 28 "No space left on device"
    voxtype:       WARN Failed to write PID file: No space left on device (os error 28)
    uwsm_app-daemon: [Errno 28] No space left on device
    
  3. wayland-wm-app-daemon.service crashes on the ENOSPC and enters a restart loop. Each restarted daemon receives a truncated request:
    uwsm_app-daemon: received:
    uwsm_app-daemon: sent: error 'Invalid arguments: ' 2
    
  4. Every app launch then fails with a critical App failure / Invalid arguments: desktop notification (urgency: 2, expireTimeout: 0, so they never expire and persist across restarts).

The machine became unusable and needed a hard restart. Note that df shows plenty of free disk throughout — the ENOSPC is shmem exhaustion, which makes this quite hard to diagnose from the symptom.

Steps to reproduce

  1. Set in ~/.config/omarchy/shell.json:
    "idle": { "screensaver": 150, "lock": 2592000 }
    
  2. Leave the machine idle for 150s so the idle cycle starts and lockTimer arms.
  3. Watch the flood:
    journalctl -f | grep QBasicTimer
    omarchy-shell idle status   # "lockDelay": 2591850, "timers": { "lock": true }
    

Expected

Either the timer is armed correctly for the configured duration, or the value is clamped/rejected — not silently wrapped into a 1ms busy loop.

Suggested fix

secondsFromConfig in plugins/services/idle/IdleModel.js already guards the low end but not the high end:

function secondsFromConfig(value, fallback) {
  var n = Number(value)
  if (!isFinite(n) || n < 0) return fallback
  return Math.floor(n)
}

Clamping to the largest value that survives the * 1000 conversion would fix it:

// Timer intervals are milliseconds in a signed 32-bit int.
var MAX_TIMER_SECONDS = 2147483  // floor(INT32_MAX / 1000)

function secondsFromConfig(value, fallback) {
  var n = Number(value)
  if (!isFinite(n) || n < 0) return fallback
  return Math.min(Math.floor(n), MAX_TIMER_SECONDS)
}

screensaverDelaySeconds (Service.qml:260) has the same exposure and would be covered by the same clamp.

Separately, it may be worth giving idle.lock an explicit "never" sentinel (e.g. 0 or false), since approximating it with a large number is what leads users into this.

System details

Omarchy 4.0.2-1
Kernel 7.1.9-arch1-2
CPU Intel Core i5-10400F
GPU NVIDIA GeForce GTX 1660 Ti (TU116)
quickshell 0.3.1-1
qt6-base 6.11.2-2

Related

  • #9361 — critical notifications never auto-expire and have no close button. That's why the resulting App failure toasts pile up and survive restarts; this bug is one way to generate them in bulk.
  • #9745 — different cause, same class of consequence (runtime tmpfs filling up and taking the session down).
  • #9496 — also concerns idle.screensaver / idle.lock handling in shell.json.

rnieuwen avatar Sep 02 '26 15:09 rnieuwen

Opened a fix in https://github.com/omacom/omarchy/pull/9846

secondsFromConfig now clamps idle timeouts to floor(INT32_MAX / 1000) so lockTimer / screensaverTimer intervals cannot wrap negative and flood the journal. Regression coverage is in test/shell.d/idle-test.sh for the 30-day case from this report.

fresh3nough avatar Sep 02 '26 16:09 fresh3nough

Confirmed, and reproduced end to end on a clean Omarchy 4.0.2 VM (quickshell 0.3.1-1, qt6-base 6.11.2-2) running current quattro — shell/plugins/services/idle is byte-identical between v4.0.2 and quattro HEAD, so nothing has moved under this since you filed.

The chain, with line numbers: secondsFromConfig (shell/plugins/services/idle/IdleModel.js:1-5) guards NaN and negatives but has no ceiling, so idle.lock: 2592000 lands intact in lockTimeoutSeconds (Service.qml:21), lockDelaySeconds becomes 2591850 (Service.qml:24), and interval: root.lockDelaySeconds * 1000 (Service.qml:267) hands 2591850000 to QQmlTimer's int interval. The conversion is a signed 32-bit wrap rather than a clamp or a binding error, which a probe under quickshell shows directly:

PROBE assigned 2591850000 stored -1703117296
QBasicTimer::start: negative intervals aren't allowed; the interval will be set to 1ms.

(-1703117296 rather than the -1702967296 in your report; the difference is the 150 s the first idle timeout takes off before the multiply. Your conclusion is unaffected.)

Two things that were worth establishing on a machine rather than from the source, because the source alone reads as if a one-shot timer clamped to 1 ms would simply fire once:

The flood is real and it does not stop. With your exact config (screensaver: 150, lock: 2592000) on a stock worker: 45,398 negative intervals lines in the first 200 seconds after the idle cycle armed the timer, 82,481 by the time the run ended. Qt refuses the negative interval and re-arms a 1 ms wake-up instead of firing, on every pass.

The lock never happens. Through all of that, omarchy-shell idle status keeps reporting "timers": { "lock": true } with inIdleCycle: true — exactly what you saw. The standalone probe agrees: the overflowed timer reads back running = true and never reaches onTriggered, while an identical timer at the clamp ceiling (2147483 s → 2147483000 ms) is stored intact. So a config meaning "lock in 30 days" is in practice "never lock, and burn a core saying so", which is worth more than the log noise it is filed as.

PR #9846 clamps secondsFromConfig to floor(INT32_MAX / 1000), which is the right place: screensaverDelaySeconds and lockDelaySeconds are both derived by subtraction from clamped values (Service.qml:22-24), so one clamp covers both timers and IdleMonitor.timeout as well.

Three other timers in the shell take an interval from user config with the same missing ceiling, and that clamp does not reach them. They are worse than this one, because they are repeat: true — the 1 ms busy loop would be permanent rather than tied to one idle cycle:

  • shell/plugins/agents/Main.qml:117 — refreshIntervalSec, floor 30, no ceiling, used at :121.
  • shell/plugins/panels/weather/Panel.qml:141 — refreshMinutes, floor 1, no ceiling, multiplied by 60000 at :469, so it wraps above 35791.
  • shell/plugins/bar/Bar.qml:1835 — a custom bar widget's interval setting, floor 1, no ceiling.

(tailscale and dropbox are safe: both go through intSetting(..., 5, 3600), which caps them.)

Reviewed by Claude Opus 5 in Claude Code, with an independent second opinion from Codex (gpt-5.6-sol) at xhigh reasoning. Codex agreed the overflow is real and that the clamp is complete for the idle service, and it independently found the same three uncapped timers elsewhere; it disputed the sustained warning rate, reading the one-shot timer as something that would fire immediately at 1 ms and stop. That is what the worker run above was for, and the measurement is against it. This is now waiting on a maintainer review of #9846.

omarchybot avatar Sep 03 '26 12:09 omarchybot

An update on where the fix stands, since the pull request linked above is no longer the one. #9846 was closed in favour of #7578, which makes the same change: it clamps both idle timeouts in secondsFromConfig (shell/plugins/services/idle/IdleModel.js) to floor(INT32_MAX / 1000) seconds, so neither the lock nor the screensaver timer interval can wrap negative. #7578 has been reproduced on a disposable Omarchy VM (the negative-interval flood on quattro, quiet on the branch, back again with the clamp reverted), its test suite passes there, and it is waiting on the maintainer.

This issue also reports the same bug as #7506, filed on 19 August with lock: 999999999: same overflow in lockTimer, same flood filling the runtime tmpfs, same App failure: Invalid arguments: at the end of it. #7578 closes #7506. I tried to close this one as its duplicate and to link it to #7578 as well, and both were refused because no second opinion could be had today: the reviewer's daily budget is spent, and a duplicate close needs a second model to agree. So this stays open for the maintainer, who can close it alongside #7506 when #7578 lands.

Checked by Claude Opus 5.5 alone, comparing this report with #7506 and the two fix pull requests; the second opinion (Codex Medium) did not run on this pass.

omarchybot avatar Oct 09 '26 13:10 omarchybot

Same symptom chain here on Omarchy 4.0.6-1 (stable) / Quickshell 0.3.2 / Qt 6.12.0, but with a trigger the current analysis does not cover — so clamping the configured idle value alone would not have prevented this occurrence.

Config rules out the documented trigger. ~/.config/omarchy/shell.json has "idle": { "screensaver": 45, "lock": 300 }, and stay-awake is enabled (stay-awake: enabled state-file), so the idle cycle is cancelled and lockTimer never arms at all.

Trigger: the European DST rollback. The storm started within ~100 ms of the clock stepping back one hour, and ran ~2,000 warnings/s for the rest of the session:

2026-10-24 19:56:20          last normal log line (7 h of complete quiet before this)
2026-10-25 02:59:59.888 CEST first warning      <- DST rollback instant
2026-10-25 02:00:00.000 CET  storm continues after the clock stepped back
2026-10-25 02:54:00.600 CET  log file stops growing: tmpfs at 100 %, writes failing

The kernel's own log timestamps confirm the clock step independently of the shell log:

2026-10-25T02:59:46+02:00 omamen kernel: [UFW BLOCK] ...
2026-10-25T02:00:06+01:00 omamen kernel: [UFW BLOCK] ...

Per-second journal sampling before the storm was vacuumed away — 0 warnings at 01:00, 03:30, 04:00, 05:00, 07:00, 08:00; 2,361 at 02:00, 2,042 at 02:30, 2,377 at 02:59. systemd-journald also noticed: Suppressed 24507 messages from [email protected].

Note the message text here is QTimer::start, not the QBasicTimer::start in the original report — Qt 6.12 vs whatever produced yours, but worth knowing if anything matches on that string.

Impact, exactly per your step 2. One instance's log reached 735 MiB / 6,759,506 lines and exhausted the 778 MiB /run/user/1000; after that wayland-wm-app-daemon crash-looped and every app launch failed:

$ df -h /run/user/1000
tmpfs  778M  778M  20K  100% /run/user/1000

uwsm_app-daemon: [Errno 28] No space left on device
systemd: wayland-wm-app-daemon.service: Main process exited, status=1/FAILURE (restart counter 3)
uwsm_app-daemon: error flag /run/user/1000/uwsm/app_daemon_error exists
uwsm_app-daemon: sent: error 'Invalid arguments: ' 2

i.e. the critical App failure / Invalid arguments: notification on every launch, with df showing plenty of free disk space the whole time.

Owning timer is unidentified. The warning carries no QML file/line. I ruled out the idle service (latches above), the menuvitals sample timer (interval: root.intervalMs, clamped >= 1000), and the OSD hideTimer (interval: root.duration, only restart()ed when duration > 0). Remaining suspects are Timers bound to computed properties: lock-explorer/Service.qml:3962 (root.blankDelay), agents/Main.qml:121, dropbox|tailscale/Service.qml (refreshIntervalSec * 1000), weather/Panel.qml:472.

Mechanically, QTimer::start is only reached from an explicit start()/restart() or from re-evaluating the interval binding of a running QML Timer, so this is a timer that is re-armed ~2,000×/s, not merely one that repeats. To go negative at a clock rollback the interval needs to come from wall-clock arithmetic where now moving backwards makes the expression negative.

Suggestion: whatever fix lands should (a) clamp on assignment rather than only validating shell.json, so wall-clock-derived intervals cannot wrap, and (b) bound the per-instance log.log itself — a single instance reaching 735 MiB is enough to exhaust the tmpfs. The related issues (#13287, #13651, #15441, #15552) cover instance directories and one BlueZ-driven log.qslog growth, not this.

Local mitigation, in case it helps others hitting the consequence: a user timer truncating any log.log/log.qslog over 20 MiB in $XDG_RUNTIME_DIR/quickshell once a minute (in-place, so Quickshell's open fd stays valid and the shell's journal copy — systemd-cat -t omarchy-shell — keeps the history), plus SystemMaxUse=500M for journald, since the storm filled the journal too.

jiri-cermak avatar Oct 25 '26 09:10 jiri-cermak

Closing this as a duplicate of #7506, filed on 19 August: the same overflow, from the same cause, needing the same fix. A large idle.lock (2592000 here, 999999999 there) minus the screensaver timeout is multiplied by 1000 into lockTimer's signed 32-bit interval, it wraps negative, Qt re-arms at 1 ms and warns on every pass, and the flood fills /run/user/<uid> until wayland-wm-app-daemon fails every launch with App failure: Invalid arguments:. It is still there on current quattro (e2c7007c1): the binding this report quotes has become an assignment when each idle cycle starts (shell/plugins/services/idle/Service.qml:105, and :97 for the screensaver), but secondsFromConfig in IdleModel.js still has no ceiling, so lock: 2592000 still hands 2,591,850,000 ms to the timer. Thank you, @rnieuwen, for the detailed report; reopen this if you think it is a different bug.

Where the fix stands has changed since my last comment. #7578 was closed by its author on 31 October without being merged. The open fix is now #13921, which caps both timeouts in secondsFromConfig at 2147483 seconds, so neither timer interval nor IdleMonitor.timeout can overflow, and it is waiting on the maintainer. Both reviewers noticed one problem in it: the cap is computed with Math.floor at the top level of the .js module, the pattern #15771 found can crash Qt while a Repeater incubates. The literal 2147483 would avoid that. That will be raised on #13921 itself.

@jiri-cermak, your storm has a different cause, and it is already fixed. With stay-awake on, the idle timers never arm. The timer that matches yours is the bar clock: Quickshell's SystemClock scheduled its next tick from local wall time, and in the repeated hour after the clocks go back that target resolved to the first pass, so the delay came out negative, it re-armed at 1 ms, and it flooded the log for the whole hour. #16684 (merged 1 November, closes #16677) replaced it in both the bar clock and the calendar panel with a timer scheduled from epoch milliseconds, which never repeat, and added a test for the 25 October fold in Europe/Berlin. It is in v4.5.0-rc1 and later, not 4.0.6.

Checked by Claude Opus 5.5 by reading current quattro, both reports, and the open and closed fix pull requests. Nothing was run on a worker this time, since the overflow was already reproduced on a disposable Omarchy VM against this idle code on 31 October. The second opinion came from Codex Medium and muse-wonder (via pi, thinking high). Each was given the reports and the diffs without my conclusions. Both found the bug still on quattro, both found this the same bug as #7506, both raised the Math.floor problem in #13921, and both traced the DST storm to the clock fixed by #16684. They could read this session's notes, so their independence is not guaranteed.

omarchybot avatar Nov 01 '26 23:11 omarchybot