Bug 1474

Summary: Finding Temp folder fails when username contains parenthesis
Product: [JogAmp] Gluegen Reporter: Tony <trozzi1>
Component: coreAssignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: critical CC: trozzi1
Priority: P2    
Version: 2.6.0   
Hardware: All   
OS: windows   
Type: DEFECT SCM Refs:
c8cb87e17a14281a9d0e2f311b8534ecb7ac00b4 0f731bfabcdd19665c3c09c5f40f898101c501c9
Workaround: ---

Description Tony 2023-10-16 18:20:36 CEST
The following stacktrace occurs on Windows 10/11 when the user's name contains a parenthesis.

---------------------------------------------------------------------------------
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(AccessController.java:318)
        at com.jogamp.common.os.Platform.<clinit>(Platform.java:290)
        at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:154)
        ...

Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: S:\natives\windows-amd64\gluegen_rt.dll
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2398)
        at java.base/java.lang.Runtime.load0(Runtime.java:785)
        at java.base/java.lang.System.load(System.java:1979)
        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(AccessController.java:318)
        at com.jogamp.common.os.Platform.<clinit>(Platform.java:290)
        at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:154)
        ...
---------------------------------------------------------------------------------

I believe the source of the crash is from the method 'testDirExec'. When it tries to run the batch file to check for executable permissions, it fails because it incorrectly handles the filepath with special characters.

The actual value of the TEMP environment variable is of the form "C:\Users\(ABC)abc\AppData\Local\Temp"
I set the properties "jogamp.debug.IOUtil.Exe" and "jogamp.debug" to true to debug it and got:

Exe-Tst: 'C:\Users\' is not recognized as an internal or external command, operable program or batch file.

I've tested this with multiple users containing parenthesis and multiple users without, and the users with the parethesis consistently fail.

I'm using an older version of gluegen so this may have been fixed already, but after quickly scanning the source code on github it doesn't look different.
Comment 1 Sven Gothel 2023-10-16 18:52:04 CEST
Thank you Tony!
Will be resolved for 2.6.0.
Comment 2 Sven Gothel 2023-11-28 03:57:58 CET
commit c8cb87e17a14281a9d0e2f311b8534ecb7ac00b4

    Bug 1474: Allow temp folder for exe-file test to contain parenthesis on Windows
    
    If the temp path contains parenthesis on Windows, e.g. the username or the sub-temp folder,
    the used exeTestFile.getCanonicalPath() can't be used by 'Runtime.getRuntime().exec( path )'.
    
    Example: C:\Users\(ABC)abc\AppData\Local\Temp
    Output: Exe-Tst: 'C:\Users\' is not recognized as an internal or external command, operable program or batch file.
    
    Hence the complete canonical path must be quoted, i.e.
    Path: "C:\Users\(ABC)abc\AppData\Local\Temp"
Comment 3 Sven Gothel 2023-11-28 10:15:09 CET
commit 0f731bfabcdd19665c3c09c5f40f898101c501c9

    Bug 1474: Only quote exe-file path on Windows for execution
    
    Double quoting of the exe-file for execution is only allowed and required on Window.