[Xfce-bugs] [Bug 15971] New: All monitors turn off when adding or removing one due to uninitialized values in crtc struct

bugzilla-daemon at xfce.org bugzilla-daemon at xfce.org
Wed Sep 18 02:19:59 CEST 2019


https://bugzilla.xfce.org/show_bug.cgi?id=15971

            Bug ID: 15971
           Summary: All monitors turn off when adding or removing one due
                    to uninitialized values in crtc struct
    Classification: Xfce Core
           Product: Xfce4-settings
           Version: unspecified
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: Medium
         Component: Display Settings
          Assignee: xfce-bugs at xfce.org
          Reporter: a.j.buxton at gmail.com
  Target Milestone: Xfce 4.14

Wen you connect or disconnect a monitor to the system, display settings tries
to re-configure the screen appropriately. It looks for a saved profile matching
the set of connected monitors to apply. If there is no such saved profile it
attempts to come up with a reasonable default.

The problem happens because during this process it tries to calculate the
screen size required to contain all monitors. In doing this it takes in to
account the monitor's scalex and scaley. These are crtc->scalex and
crtc->scaley in the code. The calculation looks like this:

https://git.xfce.org/xfce/xfce4-settings/tree/xfsettingsd/displays.c?id=a5ed05fe5e65a501a56eb632c5301e806633902e#n1265

    helper->width = MAX (helper->width, crtc->x + crtc->width * crtc->scalex);
    helper->height = MAX (helper->height, crtc->y + crtc->height *
crtc->scaley);

This runs for each monitor to accumulate the right-most and bottom-most
coordinates of all monitors.

The crtc struct is initialized here:

https://git.xfce.org/xfce/xfce4-settings/tree/xfsettingsd/displays.c?id=a5ed05fe5e65a501a56eb632c5301e806633902e#n1113

Notice that scalex and scaley are not initialized in this code. They are only
initialized here:

https://github.com/xfce-mirror/xfce4-settings/blob/master/xfsettingsd/displays.c#L849

That piece of code runs when loading a profile from xfconf, and that only
happens if your monitor configuration has a matching profile. If you add or
remove a monitor such that you are in a state that doesn't match any profile,
then scalex and scaley are used uninitialized in the screen calculation,
meaning that they have value 0, and it thinks that all your monitors are 0x0.
The screen size then ends up as the rectangle containing all the top left
coordinates of all monitors. Display settings then thinks your monitors cannot
fit on the screen, so it turns them off. Now all your monitors are turned off
and you can't turn them back on unless you can put them back into a state that
matches a saved profile, or you reboot.

So the question is how to fix this. It would be trivial to initialize the crtc
struct with 1 instead of 0 for scale. This prevents the problem from happening
for me, however I do not use the scale feature at all, and this may have
side-effects for people who do.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Xfce-bugs mailing list