<?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>1076</bug_id>
          
          <creation_ts>2014-09-22 23:36:10 +0200</creation_ts>
          <short_desc>Fix race conditions in GLDrawableHelper glRunnable and Animator* for unhandled exceptions</short_desc>
          <delta_ts>2019-03-29 17:54:47 +0100</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Jogl</product>
          <component>core</component>
          <version>2.3.0</version>
          <rep_platform>All</rep_platform>
          <op_sys>all</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>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Sven Gothel">sgothel</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          <cc>sgothel</cc>
          
          <cf_type>DEFECT</cf_type>
          <cf_scm_refs>c298b4317a30cc453a2350ebeb5ab3570a4c107d
cef7ba607ad7e8eb1ff2a438d77710a29aa0bda6
66ecb6c386d5c3d87d8be2600a0c7dd7d71a4329</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4261</commentid>
    <comment_count>0</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-09-22 23:36:10 +0200</bug_when>
    <thetext>commit c298b4317a30cc453a2350ebeb5ab3570a4c107d:

GLDrawable.invoke(..) regression of 
commit c77b8f586cb2553582a42f5b90aeee5ef85f1efe:
  &apos;wait&apos; was not set to false, if &apos;deferredHere&apos; was forced to &apos;false&apos;.
  This could lead to the situation where GLRunnableTask
  will catch the exception and supresses it.

Animator/FPSAnimator post exception propagation code
   animThread = null; notifyAll();
must be complete to finalize animator state in case of an exception.
Decorate &apos;handleUncaughtException(..)&apos; w/ try { } finally { }
where the latter ensures the mentioned &apos;closure&apos;.

+++

commit cef7ba607ad7e8eb1ff2a438d77710a29aa0bda6:

Fix synchronization issues in GLDrawableHelper.flushGLRunnables():
  - Querying &apos;glRunnables.size()&apos; is not synchronized, only its reference is volatile,
    not the instance&apos;s own states.

  - &apos;flushGLRunnable()&apos; must operates while acquired the &apos;glRunnable&apos; lock.

  - &apos;glRunnables&apos; are no more volatile

  - introduced volatile &apos;glRunnableCount&apos;, allowing &apos;display(..)&apos; method
    to pre-query whether blocking &apos;execGLRunnables(..)&apos; must be called.
    This is risk (deadlock) free.

Also fixes rare deadlock in animator display-exception / GLAD.invoke(wait=true, ..) case:
  - &apos;GLDrawableHelper.invoke(.., GLRunnable)&apos; acquires the &apos;glRunnable&apos; lock.
  - Then it queries animator state, which is blocking.
  - Hence animator&apos;s &apos;flushGLRunnable()&apos; call must happen outside the animator lock</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4264</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2014-09-23 04:00:17 +0200</bug_when>
    <thetext>commit 66ecb6c386d5c3d87d8be2600a0c7dd7d71a4329:

Fix synchronization issues in Animator* Exception case

Refines commit cef7ba607ad7e8eb1ff2a438d77710a29aa0bda6

- The animator monitor-lock was still hold in the post finally block
  issuing flushGLRunnables(), due to intrinsic monitor release (in finally):
   - &lt;http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-2.html#jvms-2.11.10&gt;
   - &lt;http://stackoverflow.com/questions/10743285/behavior-of-a-synchronized-method-with-try-and-finally&gt;

- Further: AnimatorBase.flushGLRunnables() acquired the lock itself (duh!)

This commit removes the requirement for finally altogether
by simply return a boolean from handleUncaughtException(caughtException),
where false denotes the caller to propagate the exception itself (no handler).

Post synchronized block then issues flushGLRunnables() and
exceptation propagation as required.

AnimatorBase.flushGLRunnables() &apos;synchronized&apos; modifier is removed.

Further, ThreadDeath is being propagated if caught.
Here the finally block is also removed - redundant.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>