Skip to content

Cap idle timeouts at the longest interval a timer can hold - #14581

Closed
omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-7506
Closed

omarchybot wants to merge 1 commit into
quattrofrom
fix/issue-7506

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

Qt timer intervals are int32 milliseconds. The idle service turns idle.lock and idle.screensaver into seconds with no upper bound and multiplies the delay by 1000 when it arms a timer, so any timeout past 2147483 seconds (about 24.8 days) wraps negative. The natural "never lock" value, 999999999, is well past that. Qt rejects the negative interval with QBasicTimer::start: negative intervals aren't allowed every millisecond of the idle cycle, and the shell's instance log grows until it fills $XDG_RUNTIME_DIR. After that, uwsm's app daemon fails with ENOSPC and no application launches.

This caps the value in secondsFromConfig, where both settings enter the service. The first-idle timeout and both delays are derived from the capped values, so the screensaver timer, the lock timer and the IdleMonitor timeout all stay in range for every combination of the two settings. A value above the cap now means about 24.8 days. 0 still disables the action, which is the setting for never locking.

Reproduced on a worker running the real shell with screensaver: 3, lock: 999999999. On quattro, 25 seconds of idle logged about 18,400 warnings (2.2 MB). With this change it logged none, and the lock timer was armed at 2147483 seconds. Reverting it brought the warnings back. Codex Medium reviewed the fix over two rounds. It asked for the boundary and pairing cases now in idle-test.sh, and found nothing open in the final diff.

Fixes #7506

Qt timer intervals are int32 milliseconds, so an idle.lock or idle.screensaver past 2147483 seconds (about 24.8 days) wrapped negative when the service multiplied it by 1000. Qt rejected it with a warning every millisecond of the idle cycle, and the shell's instance log filled $XDG_RUNTIME_DIR until uwsm could no longer launch apps. Capping in secondsFromConfig keeps both timers and the IdleMonitor timeout in range for every combination of the two settings; 0 still disables.

Fixes #7506

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Caps idle timeout values to prevent timer overflow.

This PR appears safe to merge.

What we checked:

  • Oversized settings overflow timers: Both configured values are capped at 2,147,483 seconds. The first deadline and nonnegative delays cannot exceed that value, so multiplying them by 1,000 stays below 2,147,483,647.

Summary

Caps configured idle timeouts at 2,147,483 seconds before the service computes timer delays.

  • Keeps the resulting millisecond intervals within the timer limit.
  • Preserves zero as the value that disables an action.
  • Adds checks for the boundary, oversized settings, and screensaver/lock pairings.
  • No actionable issues found. Tests were inspected, not executed.
  • Author omarchybot explicitly describes oversized settings becoming about 24.8 days; that timing change is intentional.

Reviews (1) · Last reviewed commit: "Cap idle timeouts at the longest interva..." · Reviewed by Greptile

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

Heads-up: this is the same cap as #13921 (@Coding-Sparrow), which is open and mergeable: Math.min(Math.floor(n), Math.floor(2147483647 / 1000)) in secondsFromConfig, plus a manual note. #7578 is another open take, and #11136 does the same but now conflicts. It would be good to land one (this one has the nicest pairing tests) and close the rest, crediting the earlier authors.

@omarchybot

Copy link
Copy Markdown
Collaborator Author

Closing this as a duplicate of #7578, which was opened earlier against quattro and makes the same fix for the same bug (#7506). Both cap secondsFromConfig in shell/plugins/services/idle/IdleModel.js at Math.floor(2147483647 / 1000) seconds, so a timeout like 999999999 can no longer wrap the timer's int32 millisecond interval negative and flood the shell log. The only difference is in the tests. This one adds pairing cases for the derived first-idle timeout and delays. #7578 asserts the ceiling and checks that Service.qml reads both timeouts through secondsFromConfig. Because every derived delay is bounded by the capped values, the pairing cases cover nothing the cap doesn't already guarantee. The older pull request keeps the credit.

#13921 and #11136 are later takes on the same bug and are left to the maintainer. #11136 clamps the intervals in Service.qml instead, and it currently conflicts.

I compared the two diffs by reading them. Nothing was run for this decision. Codex Medium classified this one separately as a bug, and omabot close-duplicate asked it separately whether the two are the same change. If this is wrong, reopen it.

@omarchybot omarchybot added the duplicate This issue or pull request already exists label Oct 16, 2026
@omarchybot omarchybot closed this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

idle.lock above ~24.8 days overflows the int32 timer ms: 1ms timer storm fills $XDG_RUNTIME_DIR and breaks all app launching

2 participants