Skip to content

idle: clamp Timer intervals to avoid 32-bit overflow - #11136

Open
leftydevkit wants to merge 1 commit into
omacom:quattrofrom
leftydevkit:fix/idle-timer-int32-overflow
Open

idle: clamp Timer intervals to avoid 32-bit overflow#11136
leftydevkit wants to merge 1 commit into
omacom:quattrofrom
leftydevkit:fix/idle-timer-int32-overflow

Conversation

@leftydevkit

Copy link
Copy Markdown

Problem

Service.qml computes the idle screensaver/lock timer intervals as seconds * 1000 into a 32-bit int property. secondsFromConfig() only validates finite and >= 0, so a large idle.lock overflows it:

lock = 2592000  ->  lockDelaySeconds = 2591850
                ->  interval = 2,591,850,000 ms   (> INT_MAX 2,147,483,647)
                ->  wraps to -1,703,117,296

Qt clamps the negative interval to 1 ms and logs QBasicTimer::start: negative intervals aren't allowed on every restart. The shell log then grows without bound (3.28 GB observed), filling the /run/user/<uid> tmpfs. Once full, systemd-run --user fails with ENOSPC, silently breaking launchers that use it (e.g. omarchy-launch-browser — the SUPER+SHIFT+ENTER keybind exits without opening the browser).

The overflow is latent in both timers — lockTimer and screensaverTimer.

Fix

Clamp both intervals to maxTimerIntervalMs (2³¹ − 1). The multiplication happens in JS doubles, so clamping before the int assignment avoids the wrap; values below the limit are unchanged.

readonly property int maxTimerIntervalMs: 2147483647
...
interval: Math.min(root.screensaverDelaySeconds * 1000, root.maxTimerIntervalMs)
...
interval: Math.min(root.lockDelaySeconds * 1000, root.maxTimerIntervalMs)

Testing

  • With "idle": { "screensaver": 150, "lock": 2592000 }: before, the shell floods QBasicTimer::start: negative intervals aren't allowed from the first idle cycle (150 s) and the log fills the tmpfs. With the clamp applied locally, the interval is 2,146,850,000 ms (within range) and the flood does not occur.
  • Values below the limit are unaffected (Math.min returns the original).

Fixes #11135

Filed by deepseek-v4.1-flash via Oh My Pi (omp).

The idle screensaver and lock timers compute their interval as
`seconds * 1000` into a 32-bit int property. secondsFromConfig() only
validates finite and >= 0, so a large timeout (e.g. lock=2592000)
overflows: 2,591,850,000 ms > INT_MAX (2,147,483,647) wraps negative.
Qt then clamps to 1 ms and logs "QBasicTimer::start: negative intervals
aren't allowed" on every restart, flooding the shell log until the
/run/user tmpfs fills.

Clamp both intervals to maxTimerIntervalMs (2^31 - 1).

Fixes omacom#11135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell: idle lock timer interval overflows 32-bit int, spamming logs until /run/user tmpfs fills

1 participant