Bug 1028 - AMD Windows driver thread hinders JVM process to exit/end, caused by _not_ destroying the SharedResource context
Summary: AMD Windows driver thread hinders JVM process to exit/end, caused by _not_ de...
Status: RESOLVED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: core (show other bugs)
Version: 2
Hardware: pc_x86_64 windows
: P3 normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2014-07-04 00:19 CEST by raptor
Modified: 2014-08-08 15:16 CEST (History)
6 users (show)

See Also:
Type: DEFECT
SCM Refs:
b66b068b5c1c238ea702ba7e8ea0c8a1c47cfcf1
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description raptor 2014-07-04 00:19:50 CEST
When running the code below, javaw.exe does not terminate on some environments. 

public static void main(String[] args) {
      GLProfile glpMinimal = GLProfile.get(GLProfile.GL2);
} 

This can be reproduced on the below environment and is not an issue for everybody.
It appears to be related to ATI type drivers.

* Eclipse: Version: Kepler Service Release 1  Build id: 20130919-0819
* Win 7 64 bit
* Java 1.7.0_51 64 
* ATI Catalyst drivers (14.4)


Some more info:
I did some more digging and it seams the issues is when the  function below in the JOGL API is called (seams some racing issue) :

jogamp.opengl.GLDrawableFactoryImpl.getOrCreateSharedResource

  protected final SharedResourceRunner.Resource getOrCreateSharedResource(AbstractGraphicsDevice device) {
      try {
          device = validateDevice(device);
          if( null != device) {
              return getOrCreateSharedResourceImpl( device );
          }
      } catch (GLException gle) {
          if(DEBUG) {
              System.err.println("Catched Exception on thread "+getThreadName());
              gle.printStackTrace();
          }
      }
      return null;
  }

If I replace the bold section with null, it will shutdown OK.
Comment 1 raptor 2014-07-07 12:12:59 CEST
I Forgot to clarify the bold section.

If 
"return getOrCreateSharedResourceImpl( device );" 
is replaced with "return null" 
javaw.exe will close.
Comment 2 Wade Walker 2014-07-13 22:19:19 CEST
I've tried to duplicate this on Windows 8 with nvidia drivers and eclipse 3.8.2, but I don't see the behavior. It looks like there's another user in the forum with this bug, I've asked him to enter his version info here to see if there's a pattern.
Comment 3 Rene 2014-08-05 14:09:39 CEST
I can confirm that this happens for me as well, it is not limited to eclipse it does the same if you run it as a standalone app.

I have tried this on two other computers with Nvidia graphics and it seems to work fine on those.

Win 7 64 bit
ATI Catalyst Drivers 14.4
Java 1.7.0_65
JOGL 2.1.5
Comment 4 Rene 2014-08-05 14:17:05 CEST
My graphics card: AMD Radeon HD 5670
Comment 5 Sven Gothel 2014-08-05 17:05:49 CEST
SharedResourceRunner stop() method
is invoked by JMV shutdown hook and GLProfile/GLDrawableFactory.shutdown*().

It shall issue SharedResource.releaseSharedResource() for all implementations,
e.g. X11/GLX and Windows/WGL.

+++

Root cause is a GL driver thread keeping the process alive.

+++

On X11/GLX we destroy the shared context and the shared drawable.

On Windows/WGL we only destroy the shared drawable,
knowing that destroying the shared context caused a driver bug in the past.

Will enable the shared context destruction, which is the proper way.
Comment 6 Sven Gothel 2014-08-05 17:06:22 CEST
(In reply to comment #5)
> 
> +++
> 
> Root cause is a GL driver thread keeping the process alive.

Confirmed for AMD Windows driver >= 14.4
Comment 7 Sven Gothel 2014-08-05 17:11:13 CEST
b66b068b5c1c238ea702ba7e8ea0c8a1c47cfcf1
  Enabling the SharedResource context destruction.

  Commiting this patch to see whether our jenkins builds won't crash
  due to previous experienced issues.
Comment 8 Sven Gothel 2014-08-05 20:34:15 CEST
(In reply to comment #7)
> b66b068b5c1c238ea702ba7e8ea0c8a1c47cfcf1
>   Enabling the SharedResource context destruction.
> 
>   Commiting this patch to see whether our jenkins builds won't crash
>   due to previous experienced issues.

All jenkins builds and tests passed,
leaving this patch 'in', which hopefully fixes the AMD Windows driver bug.

The latter is responsible for keeping the process alive
if an 'off-thread' context is not being destroyed.

'off-thread' is mentioned, since we haven't tested with an 
'on-thread' situation.

Aggregated build here:
  <http://jogamp.org/deployment/archive/master/gluegen_813-joal_557-jogl_1325-jocl_996/>

Test results from jenkins showing no regressions:
  <https://jogamp.org/chuck/view/fwd/job/jogl/1325/>

I close this bug for now.

If this change works and solves this issue, please confirm.

If this changes does not solve this issue,
PLEASE REOPEN!
Comment 9 Gustavo Arias 2014-08-08 15:16:43 CEST
(In reply to comment #8)
> (In reply to comment #7)
> > b66b068b5c1c238ea702ba7e8ea0c8a1c47cfcf1
> >   Enabling the SharedResource context destruction.
> > 
> >   Commiting this patch to see whether our jenkins builds won't crash
> >   due to previous experienced issues.
> 
> All jenkins builds and tests passed,
> leaving this patch 'in', which hopefully fixes the AMD Windows driver bug.
> 
> The latter is responsible for keeping the process alive
> if an 'off-thread' context is not being destroyed.
> 
> 'off-thread' is mentioned, since we haven't tested with an 
> 'on-thread' situation.
> 
> Aggregated build here:
>  
> <http://jogamp.org/deployment/archive/master/gluegen_813-joal_557-jogl_1325-
> jocl_996/>
> 
> Test results from jenkins showing no regressions:
>   <https://jogamp.org/chuck/view/fwd/job/jogl/1325/>
> 
> I close this bug for now.
> 
> If this change works and solves this issue, please confirm.
> 
> If this changes does not solve this issue,
> PLEASE REOPEN!

It works and solves the issue for me