jzy3d / jogl

Mirror of https://jogamp.org/cgit/jogl.git/
Other
6 stars 2 forks source link

java.io.IOException: Could not determine a temporary executable directory #21

Open jzy3d opened 2 years ago

jzy3d commented 2 years ago

Reported by @AstroPixelProcessor on Jogamp forum :

Running JOGL 2-4 with Temurin JDK 17 crashes on Linux Mint 20, 20.1, 20.2 and the latest 20.3 (only tested linux on amd64) with the following stacktrace which is again shows a problem with native library loading when OpenGL is initialized in my application.:

Warning: Caught Exception while retrieving executable temp base directory:
java.io.IOException: Could not determine a temporary executable directory
        at com.jogamp.common.util.IOUtil.getTempDir(IOUtil.java:1336)
        at com.jogamp.common.util.cache.TempFileCache.<clinit>(TempFileCache.java:84)
        at com.jogamp.common.util.cache.TempJarCache.initSingleton(TempJarCache.java:96)
        at com.jogamp.common.os.Platform$1.run(Platform.java:313)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        at com.jogamp.common.os.Platform.<clinit>(Platform.java:290)
        at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:154)
        at com.ariesproductions.imageViewer.ImageViewerInitializer.init(ImageViewerInitializer.java:117)
        at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.initialize(AstroPixelProcessor.java:7222)
        at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.<init>(AstroPixelProcessor.java:1482)
        at com.ariesproductions.astropixelprocessor.AstroPixelProcessor$1.run(AstroPixelProcessor.java:1090)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
        at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Can't load library: /opt/astropixelprocessor/natives/linux-amd64/libgluegen_rt.so
        at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.base/java.lang.Runtime.load0(Unknown Source)
        at java.base/java.lang.System.load(Unknown Source)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:625)
        at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)
        at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:107)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:488)
        at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:427)
        at com.jogamp.common.os.Platform$1.run(Platform.java:321)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        at com.jogamp.common.os.Platform.<clinit>(Platform.java:290)
        at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:154)
        at com.ariesproductions.imageViewer.ImageViewerInitializer.init(ImageViewerInitializer.java:117)

I noticed at the top of this thread that Ubuntu 18 had a similar problem, but that was gone in Ubuntu 20. All seems to work fine with 2.4 on Windows 10 and macOS Big Sur and Linux Fedora. I will test Ubuntu 20 tomorrow hopefully.

AstroPixelProcessor commented 2 years ago

Hi Martin,

Apologies for the delay, this is the output that I get on Linux Mint 20 with -Djogamp.debug.IOUtil:

/opt/astropixelprocessor$ ./astropixelprocessor IOUtil.getTempRoot(): tempX1 , used true IOUtil.getTempRoot(): tempX3 , used false IOUtil.getTempRoot(): tempX4 </home/mabula>, used true IOUtil.getTempRoot(): tempX2 </home/mabula/.cache>, used true IOUtil.testDirExec: </tmp/jogamp_exe_tst6252795205786161366.sh>: Caught IOException: Cannot run program "/tmp/jogamp_exe_tst6252795205786161366.sh": error=13, Permission denied java.io.IOException: Cannot run program "/tmp/jogamp_exe_tst6252795205786161366.sh": error=13, Permission denied at java.base/java.lang.ProcessBuilder.start(Unknown Source) at java.base/java.lang.ProcessBuilder.start(Unknown Source) at java.base/java.lang.Runtime.exec(Unknown Source) at com.jogamp.common.util.IOUtil.testDirExec(IOUtil.java:1049) at com.jogamp.common.util.IOUtil.testDirImpl(IOUtil.java:1107) at com.jogamp.common.util.IOUtil.getSubTempDir(IOUtil.java:1167) at com.jogamp.common.util.IOUtil.getTempDir(IOUtil.java:1282) at com.jogamp.common.util.cache.TempFileCache.(TempFileCache.java:84) at com.jogamp.common.util.cache.TempJarCache.initSingleton(TempJarCache.java:96) at com.jogamp.common.os.Platform$1.run(Platform.java:313) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at com.jogamp.common.os.Platform.(Platform.java:290) at com.jogamp.opengl.GLProfile.(GLProfile.java:154) at com.ariesproductions.imageViewer.ImageViewerInitializer.init(ImageViewerInitializer.java:117) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.initialize(AstroPixelProcessor.java:7220) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.(AstroPixelProcessor.java:1480) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor$1.run(AstroPixelProcessor.java:1088) at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.io.IOException: error=13, Permission denied at java.base/java.lang.ProcessImpl.forkAndExec(Native Method) at java.base/java.lang.ProcessImpl.(Unknown Source) at java.base/java.lang.ProcessImpl.start(Unknown Source) ... 30 more IOUtil.testDirExec(): test-exe </tmp/jogamp_exe_tst6252795205786161366.sh>, existingFile false, isNioExec true, returned -1 IOUtil.testDirExec(): abs-path : res -3 -> false IOUtil.testDirExec(): total 6ms, create 1ms, fill 3ms, execute 2ms IOUtil.testDirImpl(tempX1): , create true, exec true: false IOUtil.testDirExec: </home/mabula/.cache/jogamp_exe_tst11647876237856982131.sh>: Caught IOException: Cannot run program "/home/mabula/.cache/jogamp_exe_tst11647876237856982131.sh": error=13, Permission denied java.io.IOException: Cannot run program "/home/mabula/.cache/jogamp_exe_tst11647876237856982131.sh": error=13, Permission denied at java.base/java.lang.ProcessBuilder.start(Unknown Source) at java.base/java.lang.ProcessBuilder.start(Unknown Source) at java.base/java.lang.Runtime.exec(Unknown Source) at com.jogamp.common.util.IOUtil.testDirExec(IOUtil.java:1049) at com.jogamp.common.util.IOUtil.testDirImpl(IOUtil.java:1107) at com.jogamp.common.util.IOUtil.getSubTempDir(IOUtil.java:1167) at com.jogamp.common.util.IOUtil.getTempDir(IOUtil.java:1288) at com.jogamp.common.util.cache.TempFileCache.(TempFileCache.java:84) at com.jogamp.common.util.cache.TempJarCache.initSingleton(TempJarCache.java:96) at com.jogamp.common.os.Platform$1.run(Platform.java:313) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at com.jogamp.common.os.Platform.(Platform.java:290) at com.jogamp.opengl.GLProfile.(GLProfile.java:154) at com.ariesproductions.imageViewer.ImageViewerInitializer.init(ImageViewerInitializer.java:117) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.initialize(AstroPixelProcessor.java:7220) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.(AstroPixelProcessor.java:1480) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor$1.run(AstroPixelProcessor.java:1088) at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.io.IOException: error=13, Permission denied at java.base/java.lang.ProcessImpl.forkAndExec(Native Method) at java.base/java.lang.ProcessImpl.(Unknown Source) at java.base/java.lang.ProcessImpl.start(Unknown Source) ... 30 more IOUtil.testDirExec(): test-exe </home/mabula/.cache/jogamp_exe_tst11647876237856982131.sh>, existingFile false, isNioExec true, returned -1 IOUtil.testDirExec(): abs-path </home/mabula/.cache>: res -3 -> false IOUtil.testDirExec(): total 3ms, create 1ms, fill 0ms, execute 2ms IOUtil.testDirImpl(tempX2): </home/mabula/.cache>, create true, exec true: false IOUtil.testDirExec: </home/mabula/jogamp_exe_tst1955596410558205141.sh>: Caught IOException: Cannot run program "/home/mabula/jogamp_exe_tst1955596410558205141.sh": error=13, Permission denied java.io.IOException: Cannot run program "/home/mabula/jogamp_exe_tst1955596410558205141.sh": error=13, Permission denied at java.base/java.lang.ProcessBuilder.start(Unknown Source) at java.base/java.lang.ProcessBuilder.start(Unknown Source) at java.base/java.lang.Runtime.exec(Unknown Source) at com.jogamp.common.util.IOUtil.testDirExec(IOUtil.java:1049) at com.jogamp.common.util.IOUtil.testDirImpl(IOUtil.java:1107) at com.jogamp.common.util.IOUtil.getSubTempDir(IOUtil.java:1167) at com.jogamp.common.util.IOUtil.getTempDir(IOUtil.java:1298) at com.jogamp.common.util.cache.TempFileCache.(TempFileCache.java:84) at com.jogamp.common.util.cache.TempJarCache.initSingleton(TempJarCache.java:96) at com.jogamp.common.os.Platform$1.run(Platform.java:313) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at com.jogamp.common.os.Platform.(Platform.java:290) at com.jogamp.opengl.GLProfile.(GLProfile.java:154) at com.ariesproductions.imageViewer.ImageViewerInitializer.init(ImageViewerInitializer.java:117) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.initialize(AstroPixelProcessor.java:7220) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.(AstroPixelProcessor.java:1480) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor$1.run(AstroPixelProcessor.java:1088) at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.run(Unknown Source) Caused by: java.io.IOException: error=13, Permission denied at java.base/java.lang.ProcessImpl.forkAndExec(Native Method) at java.base/java.lang.ProcessImpl.(Unknown Source) at java.base/java.lang.ProcessImpl.start(Unknown Source) ... 30 more IOUtil.testDirExec(): test-exe </home/mabula/jogamp_exe_tst1955596410558205141.sh>, existingFile false, isNioExec true, returned -1 IOUtil.testDirExec(): abs-path </home/mabula>: res -3 -> false IOUtil.testDirExec(): total 6ms, create 1ms, fill 0ms, execute 5ms IOUtil.testDirImpl(tempX4): </home/mabula>, create true, exec true: false IOUtil.testDirImpl(temp01): , create true, exec false: true IOUtil.testDirImpl(temp01): </tmp/jogamp_0000>, create true, exec false: true IOUtil.getTempRoot(): temp dirs: exec: null, noexec: /tmp/jogamp_0000 Warning: Caught Exception while retrieving executable temp base directory: java.io.IOException: Could not determine a temporary executable directory at com.jogamp.common.util.IOUtil.getTempDir(IOUtil.java:1336) at com.jogamp.common.util.cache.TempFileCache.(TempFileCache.java:84) at com.jogamp.common.util.cache.TempJarCache.initSingleton(TempJarCache.java:96) at com.jogamp.common.os.Platform$1.run(Platform.java:313) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at com.jogamp.common.os.Platform.(Platform.java:290) at com.jogamp.opengl.GLProfile.(GLProfile.java:154) at com.ariesproductions.imageViewer.ImageViewerInitializer.init(ImageViewerInitializer.java:117) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.initialize(AstroPixelProcessor.java:7220) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.(AstroPixelProcessor.java:1480) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor$1.run(AstroPixelProcessor.java:1088) at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.run(Unknown Source) IOUtil.testDirImpl(testDir): </tmp/jogamp_0000/file_cache>, create true, exec false: true Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Can't load library: /opt/astropixelprocessor/natives/linux-amd64/libgluegen_rt.so at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source) at java.base/java.lang.Runtime.load0(Unknown Source) at java.base/java.lang.System.load(Unknown Source) at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:625) at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64) at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:107) at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:488) at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:427) at com.jogamp.common.os.Platform$1.run(Platform.java:321) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at com.jogamp.common.os.Platform.(Platform.java:290) at com.jogamp.opengl.GLProfile.(GLProfile.java:154) at com.ariesproductions.imageViewer.ImageViewerInitializer.init(ImageViewerInitializer.java:117) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.initialize(AstroPixelProcessor.java:7220) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor.(AstroPixelProcessor.java:1480) at com.ariesproductions.astropixelprocessor.AstroPixelProcessor$1.run(AstroPixelProcessor.java:1088) at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.desktop/java.awt.EventQueue$4.run(Unknown Source) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.desktop/java.awt.EventDispatchThread.run(Unknown Source) ./astropixelprocessor: line 21: exit: 0PK: numeric argument required

So it seems that we have a clear permissions issue here somehow. The odd thing is that my application copies other native libs for another dependency into /tmp without any issues. I wrote the code myself to make a folder in a OS temp folder and copy the lib there myself so I can load the native lib with System.Load();

These are copied by my own java code and java will load these native libs at application startup:

mabula@mabula-virtual-machine:/tmp/AstroPPLibsqfJKd$ ls libiconv.so.2.6.1 libRawConverter.so libraw.so.22.0.0

Then after this has been loaded, jogl initialises OpenGL and we crash...

Any clue what is happening from this output?

AstroPixelProcessor commented 2 years ago

This is what JOGL accomplished before crashing:

mabula@mabula-virtual-machine:/tmp/jogamp_0000/file_cache$ tree /tmp/jogamp_0000/file_cache/ /tmp/jogamp_0000/file_cache/ ├── jln6835728288635718214 │   ├── jln8087643468882149036 │   └── jln8087643468882149036.tmp ├── jln6835728288635718214.lck └── jln6835728288635718214.tmp

jzy3d commented 2 years ago

@AstroPixelProcessor found the solution which was discussed on JOGL forum so I copy paste here

After more testing and manipulating permissions of the files in my application, it turns out that the DEB packager that I used is to blame... apparently, the packager sets permissions in the files of my application in such a way that the error occurs. If I don't use the DEB packager, JOGL will run on Linux Mint 20 and also on Ubuntu 20 I can confirm with OpenJDK 17 (Temurin in my case). ...

The DEB packager that I used did NOT set the correct permissions on the jre/lib/jspanwhelper. After installation the permissions were 644 (RW,R,R). A chmod 755 /jre/lib/jspanwhelper fixed the JOGL native lib loading issue completely.

Sorry to have bothered you with this ;-) At least it is again a valuable lesson learnt, at least for me.

So that fully explains the issue I was experiencing. The Java jspawnhelper packaged in my app simply was not allowed to execute the JOGL native libs script.

AstroPixelProcessor commented 2 years ago

@jzy3d , excellent, sorry for not having posted it here as well. It was in the back of my mind that I still needed to do that...

It is good to know that the permission denied error code indicated a file permission issue in my installed package.

I would suggest to close this issue since it is solved now.