Hello Guest

[BUG] 2.9.2, index out of bounds, LinuxDisplay#getAvailableDisplayModes

  • 2 Replies
  • 11647 Views
*

Offline NateS

  • **
  • 91
    • Esoteric Software
Hi guys,

I have a Linux user that gets this crash:

Code: [Select]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.lwjgl.opengl.LinuxDisplay.getAvailableDisplayModes(SourceFile:954)
at org.lwjgl.opengl.LinuxDisplay.init(SourceFile:738)
at org.lwjgl.opengl.Display.(SourceFile:138)

This is in 2.9.2, so here's the line:
https://github.com/LWJGL/lwjgl/blob/lwjgl2.9.2/src/java/org/lwjgl/opengl/LinuxDisplay.java#L954
It would appear XRandR.getScreenNames() returns a zero length array. getScreenNames javadocs say, "the name of connected screens, or an empty array if xrandr is not supported". Why would XRandR not be supported? Should the return value of getScreenNames be checked and a better exception thrown?

The info I have from the user is he's on Linux amd64 3.17.0-pf2 and using a discrete video Nvidia video card in a laptop with no external monitors attached.

*

Offline abcdef

  • ****
  • 336
what happens if the user runs xrandr from the command line? The below is my output which matches what LWJGL picks up

Code: [Select]
$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 32767 x 32767
eDP1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 294mm x 165mm
   1920x1080      60.0*+   59.9     40.0 
   1680x1050      60.0     59.9 
   1600x1024      60.2 
   1400x1050      60.0 
   1280x1024      60.0 
   1440x900       59.9 
   1280x960       60.0 
   1360x768       59.8     60.0 
   1152x864       60.0 
   1024x768       60.0 
   800x600        60.3     56.2 
   640x480        59.9 
VGA1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

*

Offline NateS

  • **
  • 91
    • Esoteric Software
I directed the user to do that and he reported he didn't have it installed, he installed it and everything works now. Sweet, thank you! Cheers!

So for this issue, I'd be great to check if the array is empty and throw an meaningful exception so it's clear xrandr needs to be installed.