Skip to content
Commit 3710b04c authored by Maxim Kartashev's avatar Maxim Kartashev
Browse files

8280468: Crashes in getConfigColormap, getConfigVisualId, XVisualIDFromVisual on Linux

This fix addresses two possible causes of crashes:
1. makeDefaultConfig() returning NULL. The fix is to die gracefully
instead of crashing in an attempt to de-reference a NULL pointer.

2. A race condition when the number of screens change (this is only an
issue with the number of xinerama screens; the number of X11 screens is
static for the duration of the X session).

The race scenario: X11GraphisDevice.makeDefaultConfiguration() is called
on EDT so the call can race with X11GraphisDevice.invalidate() that
re-sets the screen number of the device; the latter is invoked on the
"AWT-XAWT" thread from X11GraphicsEnvironment.rebuildDevices(). So by
the time makeDefaultConfiguration() makes a native call with the
device's current screen number, the x11Screens array maintained by the
native code could have become shorter. And the native methods like
Java_sun_awt_X11GraphicsDevice_getConfigColormap() assume that the
screen number passed to them is always current and valid. The AWT lock
only protects against the changes during the native methods invocation,
but does not protect against them being called with an outdated screen
number.

The fix is to eliminate the race by protecting X11GraphisDevice.screen
with the AWT lock.
parent 6287ae37
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment