backends: Guard against NULL monitor mode during XRandR transitions#805
Open
appositeit wants to merge 1 commit intolinuxmint:masterfrom
Open
backends: Guard against NULL monitor mode during XRandR transitions#805appositeit wants to merge 1 commit intolinuxmint:masterfrom
appositeit wants to merge 1 commit intolinuxmint:masterfrom
Conversation
NVIDIA drivers can report intermediate CRTC states with no valid mode during multi-monitor reconfiguration. Several code paths dereference the monitor's current_mode without NULL checks, causing a segfault in meta_monitor_mode_foreach_crtc when the mode's crtc_modes array is accessed through a NULL pointer. Add NULL guards in: - meta_logical_monitor_foreach_crtc() — skip monitors with no mode - calculate_monitor_scale() — return 1.0 as safe default - meta_monitor_manager_is_scale_supported_by_other_monitors() — skip - derive_scale_from_crtc() — return FALSE Also reject screen sizes below 64px in meta_gpu_xrandr_read_current() as these indicate transient invalid states from the driver. Closes linuxmint#671
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
NVIDIA drivers can report intermediate CRTC states with no valid mode during multi-monitor reconfiguration (e.g. when monitors wake from DPMS sleep). Several code paths dereference
monitor->current_modewithout NULL checks, causing a segfault inmeta_monitor_mode_foreach_crtcwhen the mode'scrtc_modesarray is accessed through a NULL pointer.Solution
Add NULL guards in four functions:
meta_logical_monitor_foreach_crtc()— skip monitors with no modecalculate_monitor_scale()— return 1.0 as safe defaultmeta_monitor_manager_is_scale_supported_by_other_monitors()— skipderive_scale_from_crtc()— return FALSEAlso reject screen sizes below 64px in
meta_gpu_xrandr_read_current()as these indicate transient invalid states from the driver.Add
g_debug()logging aroundRRScreenChangeNotifyprocessing to aid future diagnosis.Testing
Tested on a single machine:
Previously this configuration would crash muffin within hours of enabling DPMS. With these guards, the NULL dereference crash path is eliminated.
This has only been tested on one machine and has not been widely tested.
Disclosure
This patch was developed with AI assistance (Claude Code). The code changes are minimal (NULL guards and a minimum size check) and have been manually reviewed.
Related issues