Displays: segfault when enabling mirror mode if no modes match
System details:
- Version: gnome-control-center 42.3
- OS: carbonOS
- DE: Graphite (wlroots based, emulates Mutter's display API), but g-c-c's behavior is buggy here regardless
How the crash happens:
- The user has two displays plugged in, which have no matching modes
-
I can't tell if this can ever happen with mutter (does mutter just inject a list of default modes? when does it do such a thing?)edit: seems like it can. See below - I was able to reproduce this on an intel Macbook (which seems to report only one 16:10 mode in wlroots) with a TV (16:9) plugged in
-
- The user tries to enable mirror mode
- ...
-
cc_display_config_dbus_generate_cloning_modes
is called - All of the calls to
monitors_has_compatible_clone_mode
return FALSE (since the monitors share no modes). Thusbest_mode
is never changed fromNULL
-
best_mode->flags |= MODE_PREFERRED
executes, causing a NULL dereference, causing a segfault -
The code that executes immediately after the call toEDIT: not really. g-c-c just ends up in a somewhat broken state. See belowcc_display_config_dbus_generate_cloning_modes
seems to be designed to be able to handle an empty list of clone modes. This leads me to believe that the situation I describe in step 1 isn't 100% out of the question
Expected behavior: Instead of crashing, g-c-c says that 'Changes cannot be applied. This could be due to hardware limitations' and doesn't let the user enable mirror mode.
EDIT: Some observations:
- According to #1437, it is possible for monitors returned by mutter to not share a resolution
- I tried skipping over the faulty instruction in GDB. In the event of an empty cloning_modes list, g-c-c emits a critical (included below) and kinda breaks the UI (half the UI seems to think mirror mode is set, but the other half thinks it isn't).
(gnome-control-center:169392): display-cc-panel-CRITICAL **: 01:36:29.134: config_ensure_of_type: assertion 'clone_mode' failed
Edited by Adrian Vovk