<AWT Dev> RFR: 8239894: Xserver crashes when the wrong high refresh rate is used

Sergey Bylokhov serb at openjdk.java.net
Tue Jan 19 09:54:00 UTC 2021


We use two different approaches to listing the display modes on the system:
 - For single-screen configuration use version 1.1 protocol XRRGetScreenInfo/XRRConfigRates/XRRConfigSizes
 - For multi-screen configuration use version 1.2 protocol: XRRGetScreenResources/XRRGetOutputInfo/XRRModeInfo

Unfortunately, the current code does not work for some specific double scan modes, it doubles the real refresh rate. If this refresh rate will be passed to the Xserver later it could hang/crash.

The same bug existed in xrandr utility before version 1.4:
https://bugs.freedesktop.org/show_bug.cgi?id=37043
https://gitlab.freedesktop.org/xorg/app/xrandr/commit/7fd4f18b649f22fad4dbf9fc64b69b3e7f172207

As suggested in the bug report I have tried to unify the code for single and multiscreen systems and use updated code currently used on the multiscreen.

But unfortunately, I have found that the multi-screen code is even more broken. The problematic code is this:

    int scr = 0, out = 0;
    if (usingXinerama && XScreenCount(awt_display) > 0) {
        out = screen;
    } else {
        scr = screen;
    }
The idea of the code is: if the passed screen is Xinerama index used by the java2d, then the "scr" will be zero, and "out" will be the "virtual" index for that screen. If the screen is X11 screen then "src" will be the correct screen and "out" will be zero.

The problem is that the code assumes that xrandr expect the "virtual" index as the "out" parameter, but this is not. This parameter is the index of the "output" such as DP1, DP2, other ports/etc.

So sometimes the code works when the first screen is connected to the first port on the video card and the second screen to the second port, otherwise, we just report data for the wrong screen or report nothing.

I did not found a reliable way to map Xinerama srceens to the xrandr. It is better to rework the java2d to use the xrandr instead of xinerama.

As a fix, I suggest dropping the code which uses the incorrect mapping screen->output. This includes the code related to the display modes added in the JDK-8167486 + JDK-8022810, and also the code related to the calculation of scale factor from the "ubuntu property" which does not work on the recent ubuntu version after migration to gnome3 added in the JDK-8149115

I will file a separate two bugs to reimplement this functionality, most probably the "display modes" will be implementing when we fully migrate to the xrandr, and calculation of the scale factor will be implemented via the gtk library.

-------------

Commit messages:
 - Report the current mode in the list of supported modes in xinerama
 - Rollback JDK-8149115, JDK-8167486, JDK-8022810

Changes: https://git.openjdk.java.net/jdk/pull/2136/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2136&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8239894
  Stats: 310 lines in 5 files changed: 3 ins; 292 del; 15 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2136.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2136/head:pull/2136

PR: https://git.openjdk.java.net/jdk/pull/2136


More information about the awt-dev mailing list