<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>761</bug_id>
          
          <creation_ts>2013-06-21 14:36:35 +0200</creation_ts>
          <short_desc>Crash during X11 shutdown using AMD fglrx driver</short_desc>
          <delta_ts>2013-06-23 01:24:57 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Newt</product>
          <component>x11</component>
          <version>1</version>
          <rep_platform>pc_x86_32</rep_platform>
          <op_sys>linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Xerxes Rånby">xerxes</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          
          
          <cf_type>---</cf_type>
          <cf_scm_refs>jogl 41c626d8a27981e694b3b728a9a2f2bc8def939d
jogl 2d32b056c7b1b6b3d071d79fb4c2d4e9113b59d5</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2699</commentid>
    <comment_count>0</comment_count>
    <who name="Xerxes Rånby">xerxes</who>
    <bug_when>2013-06-21 14:36:35 +0200</bug_when>
    <thetext>Ubuntu 12.04 32bit
The crash is found to trigger in about 1/4 runs during unclean shutdown triggered by catching an ALException inside the GLEventListener display
For more information see: http://jogamp.org/log/irc/jogamp_20130621050527.html

GL Profile     GLProfile[GL3bc/GL3bc.hw]
GL Version     3.3 (hardware) - 3.3.11627 Compatibility Profile Context [GL 3.3.0, vendor 0.0.0 (n/a)]
Quirks         [DontCloseX11Display]
Impl. class    jogamp.opengl.gl4.GL4bcImpl
GL_VENDOR      ATI Technologies Inc.
GL_RENDERER    ATI Radeon HD 4800 Series
GL_VERSION     3.3.11627 Compatibility Profile Context
GLSL           true, has-compiler-func: true, version: 3.30 / 3.30.0
GL_EXTENSIONS  196

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x730ffb40 (LWP 2614)]
0x736c5334 in _XEventsQueued (dpy=0x6fbed858, mode=2) at ../../src/xcb_io.c:350
350	../../src/xcb_io.c: Filen eller katalogen finns inte.
(gdb) bt
#0  0x736c5334 in _XEventsQueued (dpy=0x6fbed858, mode=2)
    at ../../src/xcb_io.c:350
#1  0x736b60a8 in XEventsQueued (dpy=0x6fbed858, mode=2)
    at ../../src/Pending.c:43
#2  0x6cac126b in Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0
    ()
   from /tmp/jogamp_0000/file_cache/jln137143273701419511/jln3716836924835917257/libnewt.so
#3  0xb3e0a64a in ?? ()
...

Stack: [0x730af000,0x73100000],  sp=0x730feb50,  free space=318k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libX11.so.6+0x37334]  _XEventsQueued+0x24

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  jogamp.newt.driver.x11.DisplayDriver.DispatchMessages0(JJJ)V+0
j  jogamp.newt.driver.x11.DisplayDriver.dispatchMessagesNative()V+84
j  jogamp.newt.DisplayImpl.dispatchMessages()V+112
j  jogamp.newt.DisplayImpl$3.run()V+4
j  jogamp.newt.DefaultEDTUtil$EventDispatchThread.run()V+61
v  ~StubRoutines::call_stub</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2700</commentid>
    <comment_count>1</comment_count>
    <who name="Xerxes Rånby">xerxes</who>
    <bug_when>2013-06-21 14:54:14 +0200</bug_when>
    <thetext>Workaround: shutdown using fglrx looks to behave well after removing closePendingDisplayConnections(); from X11Util

diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src
index 2d9c42e..2c69cb8 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java
@@ -212,7 +212,7 @@ public class X11Util implements ToolkitProperties {
                         // dislike closing of X11 Display&apos;s (w/ ATI driver). 
                         if( isJVMShuttingDown ) {
                             isInit = false;                            
-                            closePendingDisplayConnections();    
+                            //closePendingDisplayConnections();    
                             openDisplayList.clear();
                             reusableDisplayList.clear();
                             pendingDisplayList.clear();</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2703</commentid>
    <comment_count>2</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2013-06-23 01:24:57 +0200</bug_when>
    <thetext>Excellent - I was almost disregarding the fglrx issue.
Best thing, this leads to a proper JVM shutdown sequence and dependency.

+++

Move GLDrawableFactory.shutdownHook -&gt; NativeWindowFactory.shutdownHook, the latter handles 
customShutdownHooks for NativeWindow, JOGL and NEWT.
    
  Unifying our shutdown mechanism is required to provide a controlled shutdown sequence.
  NativeWindowFactory is chosen to be the new central entry point, 
  since it is the lowest denominator (common module).
    
    - Move GLDrawableFactory.shutdownHook -&gt; NativeWindowFactory.shutdownHook
      Reverse the shutdown dependency for clarity and availability to all modules,
      i.e. NEWT may not know about JOGL.
    
      Remove the &apos;gamma&apos; shutdown hook,
      instead simply call GLDrawableFactoryImpl.resetDisplayGamma() before destroy.
    
  NativeWindowFactory.shutdownHook handles customShutdownHooks for NativeWindow, JOGL and NEWT
      - Modules can register their shutdown runnable at head or tail of list.
      - Allows controlled shutdown across all modules.

NEWT registers one customShutdownHook @  NativeWindowFactory.shutdownHook head, 
allowing proper resource cleanup.
    
    1 WindowImpl.shutdownAll():
      - For all instances:
        - mark invalid (causes any user thread to disregard the window)
    
    2 ScreenImpl.shutdownAll():
      - Removed own shutdown-hook!
      - For all instances:
        - Reset ScreenMonitorState
    
    3 DisplayImpl.shutdownAll():
      - For all instances:
        - Remove EDT
        - closeNativeImpl
    
  Manually tested on X11 w/ NV and ATI Catalyst (fglrx)
      - DFLAGS=&quot;-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window&quot;
      - java $DFLAGS com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -time 2000 -sysExit testExit
      - valid arguments for sysExit: testExit, testError, displayExit, displayError</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>