<?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>893</bug_id>
          
          <creation_ts>2013-11-06 15:17:19 +0100</creation_ts>
          <short_desc>NewtCanvasAWT Lifecycle Race Condition (NPE on shutdown periodically)</short_desc>
          <delta_ts>2013-11-18 16:13:35 +0100</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Newt</product>
          <component>windows</component>
          <version>1</version>
          <rep_platform>pc_x86_64</rep_platform>
          <op_sys>windows</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P1</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jesse">narf_bro</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>narf_bro</cc>
          
          <cf_type>---</cf_type>
          <cf_scm_refs>d8f7418f170aba4703df2b11d5ae11598f71a796</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3277</commentid>
    <comment_count>0</comment_count>
    <who name="Jesse">narf_bro</who>
    <bug_when>2013-11-06 15:17:19 +0100</bug_when>
    <thetext>Sometimes when I shutdown by pressing the X button in the top right corner, I get a null pointer on the jawtWindow inside attachNewtChild. Call stack is below. 

All IsoCanvas.paint does is call super.paint().

Problem is a simple race condition - destroyImpl sets jawtWindow to null while paint is in progress. Null check at top of attachNewtChild() gets bypassed but by the time it hits jawtWindow.isOffscreenLayerSurfaceEnabled, jawtWindow is null.

Either need synchronization around destroy / paint or destroy needs to be called from the same EDT that&apos;s running the paint so it&apos;s sequential.

Exception in thread &quot;AWT-EventQueue-0&quot; java.lang.NullPointerException
		at com.jogamp.newt.awt.NewtCanvasAWT.attachNewtChild(NewtCanvasAWT.java:745)
		at com.jogamp.newt.awt.NewtCanvasAWT.validateComponent(NewtCanvasAWT.java:660)
		at com.jogamp.newt.awt.NewtCanvasAWT.paint(NewtCanvasAWT.java:461)
		at Iso3d.IsoCanvas.paint(IsoCanvas.java:103)
		at sun.awt.RepaintArea.paintComponent(RepaintArea.java:264)
		at sun.awt.RepaintArea.paint(RepaintArea.java:240)
		at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:347)
		at java.awt.Component.dispatchEventImpl(Component.java:4937)
		at java.awt.Component.dispatchEvent(Component.java:4687)
		at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
		at java.awt.EventQueue.access$200(EventQueue.java:103)
		at java.awt.EventQueue$3.run(EventQueue.java:688)
		at java.awt.EventQueue$3.run(EventQueue.java:686)
		at java.security.AccessController.doPrivileged(Native Method)
		at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
		at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
		at java.awt.EventQueue$4.run(EventQueue.java:702)
		at java.awt.EventQueue$4.run(EventQueue.java:700)
		at java.security.AccessController.doPrivileged(Native Method)
		at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
		at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
		at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
		at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
		at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
		at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
		at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3346</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2013-11-18 16:13:35 +0100</bug_when>
    <thetext>d8f7418f170aba4703df2b11d5ae11598f71a796
 As suggested: Employ synchronization on lifecycle actions _and_ 
 perform destroyImpl(..) always on AWT-EDT to avoid a deadlock.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>