<?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>1019</bug_id>
          
          <creation_ts>2014-06-12 08:18:29 +0200</creation_ts>
          <short_desc>Remedy of Bug 691 causes &apos;access/modify after free&apos; and crashes the app on OSX</short_desc>
          <delta_ts>2014-06-12 18:25:26 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Jogl</product>
          <component>macosx</component>
          <version>2</version>
          <rep_platform>All</rep_platform>
          <op_sys>macosx</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>critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>691</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Sven Gothel">sgothel</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>askinner</cc>
    
    <cc>harvey.harrison</cc>
          
          <cf_type>---</cf_type>
          <cf_scm_refs>5626740d14554acf7a17a73ec12b0893445832d0</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3961</commentid>
    <comment_count>0</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-06-12 08:18:29 +0200</bug_when>
    <thetext>The &apos;magic&apos; MyNSOpenGLContext::dealloc (MacOSXWindowSystemInterface-calayer.m)
of force destroying the underlying CGLContextObj of it&apos;s associated
NSOpenGLContext as introduced as a remedy of Bug 691 is plain wrong.

It was added in commit f6e6fab2a7ddfb5c9b614cb072c27ff697629161
to mitigate the experience behavior of delayed GL context
destruction when creating/destroying them multiple times
as exposed in unit test TestGLCanvasAddRemove01SwingAWT.

While this &apos;hack&apos; worked for some reason on some OSX versions,
it caused a &apos;access/modify after free&apos; issue exposed under some circumstances
and crashes the application.

The actual culprit of the delayed GL context destruction is different.
The offthread CALayer detachment and hence final destruction
issued on the main-thread is _not_ issued immediately 
due to some referencing holding by NSApp.
Issuing an empty event on the NSApp (thread) will wake up the thread
and release claimed resources.

This has been found while realizing that the GL context 
are released if the mouse is being moved (duh!).
This issue is also known when triggering stop on the NSApp (NEWT MainThread),
same remedy has been implemented here for a long time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3963</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-06-12 08:22:45 +0200</bug_when>
    <thetext>commit 5626740d14554acf7a17a73ec12b0893445832d0

fixed as described</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>