Bug 621

Summary: JVM Crashes During X11 Shutdown
Product: [JogAmp] Jogl Reporter: Rob Hatcherson <rob.hatcherson>
Component: x11Assignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: major    
Priority: ---    
Version: 2   
Hardware: All   
OS: linux   
Type: --- SCM Refs:
jogl ba846a478d616327817dd530dbdcd9a786be5b7a
Workaround: ---
Attachments: test.sh output plus the hs_err_pid dump info

Description Rob Hatcherson 2012-09-21 00:46:43 CEST
Created attachment 368 [details]
test.sh output plus the hs_err_pid dump info

Fedora 12 32-bit
JRE/JDK 7u7
GeForce 9800 GT + NVIDIA driver 304.37
JOGAMP/JOGL custom build from 09/17/2012 repos

The attachment is the output of test.sh with the complete JVM crash hs_err_pid output appended.

While testing a build from repos cloned on 09/17/2012 I started getting JVM dumps while shutting down our graphics apps.

The crashes happen on every shutdown, and always includes something like this at the top of the hs_err_pid... file:

C  [libGL.so.1+0x70d71]  fileno+0x70d71
C  [libnativewindow_x11.so+0x319a]  Java_jogamp_nativewindow_x11_X11Lib_XCloseDisplay__J+0x75
j  jogamp.nativewindow.x11.X11Lib.XCloseDisplay(J)I+0
j  jogamp.nativewindow.x11.X11Util.XCloseDisplay(J)I+66
j  jogamp.nativewindow.x11.X11Util.closePendingDisplayConnections()I+117
j  jogamp.nativewindow.x11.X11Util.shutdown()V+213
...more stuff... '

RC10 did not exhibit this behavior.

Sven has pointed out that this problem is an indication that resources are not being disposed properly.  Testing has verified that at least in simple cases the crash doesn't happen if measures are taken to make sure dispose() is called on listeners and the listeners have implemented dispose correctly.

However, some inspection among the JOGL demos (as well as our own code :-/) suggests that resource disposal may be commonly overlooked, and perhaps such a crash is too pedantic in practice and the RC10 behavior should be restored.
Comment 1 Sven Gothel 2012-09-21 22:12:20 CEST
This is a regression of JOGL commit f2cfb6119a3663715ed2d572643949b3bef58662 to fix Bug 610.
Comment 2 Sven Gothel 2012-09-21 22:19:06 CEST
    Fix Bug 621, JVM Crashes During X11 Shutdown while closing all unclosed display connections.
    
    This is a regression of JOGL commit f2cfb6119a3663715ed2d572643949b3bef58662 to fix Bug 610.
    
    Commit f2cfb6119a3663715ed2d572643949b3bef58662 closed all open display connections at
    JVM shutdown in order of their creation.
    This is required IF the driver is the proprietary ATI on X11.
    X11Util.setMarkAllDisplaysUnclosable(true) is called in this case.
    
    However, this behavior causes a SIGSEGV for other GPU driver, i.e. Nvidia :)
    
    This fix only closes the pending display connections in their respective order
    IF X11Util.getMarkAllDisplaysUnclosable() == true.
    Hence the 'new' cleanup as introduced in the offending commit
    is only performed on the erroneous ATI driver.
    
    Manually tested w/ TestGearsES2AWT, see it's commandline options for details.