Skip to content

Fix crash on invalid geometry from NVIDIA multi-monitor setups#494

Open
appositeit wants to merge 2 commits intolinuxmint:masterfrom
appositeit:fix/nvidia-geometry-validation
Open

Fix crash on invalid geometry from NVIDIA multi-monitor setups#494
appositeit wants to merge 2 commits intolinuxmint:masterfrom
appositeit:fix/nvidia-geometry-validation

Conversation

@appositeit
Copy link
Copy Markdown

@appositeit appositeit commented Mar 4, 2026

Problem

NVIDIA multi-monitor setups can report invalid intermediate geometries (e.g. 8x8 pixels) during mode switches and DPMS wake. This causes:

  1. Screensaver crash when the stage tries to render with invalid monitor geometry, leading to Gtk widget allocation failures
  2. Orphaned PAM helpers — when the screensaver crashes, cinnamon-screensaver-pam-helper processes (~12MB each) are reparented to PID 1 and accumulate over time

Solution

Commit 1: Validate geometry during monitor change events

  • C library (cs-screen-x11.c): Add has_valid_monitor_dimensions() check with rollback to previous valid state and a 500ms deferred re-check when invalid geometry is detected
  • Python stage (stage.py): Add MIN_MONITOR_DIMENSION (64px) checks before refreshing monitor views, with deferred re-check on invalid geometry
  • Both on_monitors_changed and on_screen_size_changed handlers are guarded in both C and Python layers

Commit 2: Add exception handler and PAM helper cleanup on exit

  • sys.excepthook for proper traceback logging on unhandled exceptions
  • atexit handler to kill child PAM helper processes
  • SIGTERM handler for graceful cleanup

Testing

Tested on a single machine:

  • Ubuntu 25.10 (Cinnamon 6.4, cinnamon-screensaver 6.4.0)
  • NVIDIA driver 570.133.07, proprietary
  • Dual monitor: 3440x1440 (DP) + 2560x1440 (HDMI)
  • DPMS sleep/wake cycling over multiple days with no screensaver crashes and zero orphaned PAM helpers

Previously this configuration would crash the screensaver during DPMS wake events. With these guards, invalid geometry is detected and deferred until the driver settles.

This has only been tested on one machine and has not been widely tested.

Disclosure

These patches were developed with AI assistance (Claude Code). The changes have been manually reviewed.

Related issues

NVIDIA multi-monitor setups can report invalid intermediate geometries
(e.g. 8x8) during mode switches. The C library stores this invalid
state even when the change signal is suppressed, and the Python stage
has no validation before using geometry values.

Add geometry validation with rollback and deferred re-check in the C
library (cs-screen-x11.c), and minimum dimension checks in the Python
stage before refreshing monitor views.
Unhandled exceptions produce empty error messages and leave orphaned
cinnamon-screensaver-pam-helper processes (~12MB each). Add
sys.excepthook for proper traceback logging, atexit handler to kill
child PAM helpers, and SIGTERM handler for graceful cleanup.
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.

1 participant