Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

native compiled image crashes when java.awt.Desktop.getDesktop is used #9138

Closed
damnms opened this issue Jun 18, 2024 · 13 comments
Closed

native compiled image crashes when java.awt.Desktop.getDesktop is used #9138

damnms opened this issue Jun 18, 2024 · 13 comments
Assignees

Comments

@damnms
Copy link

damnms commented Jun 18, 2024

running debian trixie with xfce and latest graalvm, i get a crash when i try to execute Desktop.getDesktop().browse(new URI("http://localhost:8080"));

log4j:WARN No appenders could be found for logger (org.gitlab.jsfdl.ApplicationConfiguration).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Fatal error reported via JNI: Could not allocate library name

Printing instructions (ip=0x0000555e70363919):
  0x0000555e70363819: 0x10 0xeb 0x88 0x48 0x89 0x6c 0x24 0x40 0x48 0x89 0x54 0x24 0x38 0x48 0x89 0x4c
  0x0000555e70363829: 0x24 0x30 0x4c 0x89 0x6c 0x24 0x28 0x4c 0x89 0x64 0x24 0x20 0x48 0x89 0x5c 0x24
  0x0000555e70363839: 0x18 0x48 0xc7 0xc0 0x00 0x00 0x00 0x00 0x4c 0x8b 0x74 0x24 0x30 0x4c 0x8b 0x7c
  0x0000555e70363849: 0x24 0x38 0x48 0x83 0xc4 0x48 0xc3 0x48 0x8b 0x6c 0x24 0x40 0x48 0x8b 0x54 0x24
  0x0000555e70363859: 0x38 0x48 0x8b 0x4c 0x24 0x30 0x4c 0x8b 0x6c 0x24 0x28 0x4c 0x8b 0x64 0x24 0x20
  0x0000555e70363869: 0x48 0x8b 0x5c 0x24 0x18 0x49 0x2b 0xc6 0x48 0xc1 0xe8 0x03 0x41 0x89 0x87 0xb0
  0x0000555e70363879: 0x00 0x00 0x00 0x41 0xc7 0x47 0x14 0x03 0x00 0x00 0x00 0xf0 0x83 0x04 0x24 0x00
  0x0000555e70363889: 0x48 0xc7 0xc0 0x00 0x00 0x00 0x00 0x4c 0x8b 0xf1 0x4c 0x8b 0xfa 0x48 0x83 0xc4
  0x0000555e70363899: 0x48 0xc3 0xcc 0xcc 0xcc 0xcc 0xcc 0x48 0x83 0xec 0x48 0x49 0x8b 0xce 0x49 0x8b
  0x0000555e703638a9: 0xd7 0x48 0x85 0xff 0x0f 0x84 0x97 0x00 0x00 0x00 0x4c 0x8b 0xff 0x48 0x8b 0x47
  0x0000555e703638b9: 0x60 0x4c 0x8b 0xf0 0x66 0x66 0x90 0x41 0x83 0xbf 0xc8 0x00 0x00 0x00 0x00 0x0f
  0x0000555e703638c9: 0x85 0xd6 0x00 0x00 0x00 0xb8 0x03 0x00 0x00 0x00 0x41 0xb8 0x01 0x00 0x00 0x00
  0x0000555e703638d9: 0xf0 0x45 0x0f 0xb1 0x47 0x14 0x90 0x0f 0x85 0xbe 0x00 0x00 0x00 0x48 0x89 0x6c
  0x0000555e703638e9: 0x24 0x40 0x48 0x89 0x54 0x24 0x38 0x48 0x89 0x4c 0x24 0x30 0x4c 0x89 0x6c 0x24
  0x0000555e703638f9: 0x28 0x4c 0x89 0x64 0x24 0x20 0x48 0x89 0x5c 0x24 0x18 0x48 0x8b 0xc7 0x4c 0x8b
  0x0000555e70363909: 0xc6 0x48 0x89 0x44 0x24 0x08 0x4c 0x89 0x44 0x24 0x10 0xe8 0x57 0xbd 0x0a 0x00
> 0x0000555e70363919: 0x90 0x41 0xc7 0x47 0x14 0x03 0x00 0x00 0x00 0xf0 0x83 0x04 0x24 0x00 0x48 0x8b
  0x0000555e70363929: 0x5c 0x24 0x18 0x48 0x8b 0x6c 0x24 0x40 0x4c 0x8b 0x64 0x24 0x20 0x4c 0x8b 0x6c
  0x0000555e70363939: 0x24 0x28 0x4c 0x8b 0x74 0x24 0x30 0x4c 0x8b 0x7c 0x24 0x38 0x48 0x83 0xc4 0x48
  0x0000555e70363949: 0xc3 0x48 0x89 0x6c 0x24 0x40 0x48 0x89 0x54 0x24 0x38 0x48 0x89 0x4c 0x24 0x30
  0x0000555e70363959: 0x4c 0x89 0x6c 0x24 0x28 0x4c 0x89 0x64 0x24 0x20 0x48 0x89 0x5c 0x24 0x18 0x48
  0x0000555e70363969: 0x89 0x74 0x24 0x10 0x48 0x89 0x7c 0x24 0x08 0x48 0x8d 0x35 0x37 0x6a 0xfa 0x03
  0x0000555e70363979: 0xbf 0x02 0x00 0x00 0x00 0x66 0x90 0xe8 0x1b 0x8a 0x03 0x00 0x90 0x48 0x8b 0x5c
  0x0000555e70363989: 0x24 0x18 0x48 0x8b 0x6c 0x24 0x40 0x4c 0x8b 0x64 0x24 0x20 0x4c 0x8b 0x6c 0x24
  0x0000555e70363999: 0x28 0x4c 0x8b 0x74 0x24 0x30 0x4c 0x8b 0x7c 0x24 0x38 0x48 0x89 0x6c 0x24 0x40
  0x0000555e703639a9: 0x48 0x89 0x54 0x24 0x38 0x48 0x89 0x4c 0x24 0x30 0x4c 0x89 0x6c 0x24 0x28 0x4c
  0x0000555e703639b9: 0x89 0x64 0x24 0x20 0x48 0x89 0x5c 0x24 0x18 0x48 0x89 0x74 0x24 0x10 0x48 0x89
  0x0000555e703639c9: 0x7c 0x24 0x08 0xbf 0x01 0x00 0x00 0x00 0xbe 0x00 0x00 0x00 0x00 0xe8 0xf5 0x91
  0x0000555e703639d9: 0x14 0x00 0x90 0x48 0x8b 0x74 0x24 0x10 0x48 0x8b 0x7c 0x24 0x08 0xe9 0x19 0xff
  0x0000555e703639e9: 0xff 0xff 0x48 0x8b 0x6c 0x24 0x40 0x48 0x8b 0x54 0x24 0x38 0x48 0x8b 0x4c 0x24
  0x0000555e703639f9: 0x30 0x4c 0x8b 0x6c 0x24 0x28 0x4c 0x8b 0x64 0x24 0x20 0x48 0x8b 0x5c 0x24 0x18
  0x0000555e70363a09: 0x49 0x2b 0xc6 0x48 0xc1 0xe8 0x03 0x41 0x89 0x87 0xb0 0x00 0x00 0x00 0x41 0xc7

Top of stack (sp=0x00007ffeb1ea5980):
  0x00007ffeb1ea5960: 0x0000000000000000 0x0000555e70363919 0x00007ffeb1ea5980 0x0000555e70363919
> 0x00007ffeb1ea5980: 0x0000000000000000 0x0000555e75e2b300 0x00007fe3eecd0248 0x0000555e75e2b300
  0x00007ffeb1ea59a0: 0x00007ffeb1ea59f0 0x0000000000000003 0x0000000000000047 0x0000555e75e2b300
  0x00007ffeb1ea59c0: 0x00007ffeb1ea6a20 0x00007fe3eecc7d3c 0x0000555e75e2db40 0x00007fe3eec1c000
  0x00007ffeb1ea59e0: 0x0000000000000000 0x0000000000000000 0x6c6f2f656d6f682f 0x7250616564492f69
  0x00007ffeb1ea5a00: 0x6a2f737463656a6f 0x64616f6c6c646673 0x646c6975622f7265 0x2f65766974616e2f
  0x00007ffeb1ea5a20: 0x6f4365766974616e 0x696c2f656c69706d 0x6165685f74776162 0x6f732e7373656c64
  0x00007ffeb1ea5a40: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x00007ffeb1ea5a60: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x00007ffeb1ea5a80: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x00007ffeb1ea5aa0: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x00007ffeb1ea5ac0: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x00007ffeb1ea5ae0: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x00007ffeb1ea5b00: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x00007ffeb1ea5b20: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x00007ffeb1ea5b40: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x00007ffeb1ea5b60: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000

VM thread locals for the failing thread 0x0000555e75e2b300:
  0: JNIThreadLocalEnvironment.jniFunctions = (bytes) 0x00007fdbef5e4008
  8: StackOverflowCheckImpl.stackBoundaryTL = (Word) 0x0000000000000001 (1)
  16: Safepoint.safepointRequested = (int) 0x7ffb9240 (2147193408)
  20: StatusSupport.statusTL = (int) 0x00000001 (1)
  24: ThreadLocalAllocation.regularTLAB = (bytes) 
    0x0000555e75e2b318: 0x00007fdbf1100000 0x00007fdbf1180000
    0x0000555e75e2b328: 0x00007fdbf11228d0 0x0000000000000000
  56: JavaFrameAnchors.lastAnchor = (Word) 0x00007ffeb1ea6a48 (140731883350600)
  64: JavaThreads.currentVThreadId = (long) 0x0000000000000001 (1)
  72: PlatformThreads.currentThread = (Object) 0x00007fdbef9a1a70
    is an object of type java.lang.Thread
  80: SubstrateDiagnostics.threadOnlyAttachedForCrashHandler = (bytes) 0x0000000000000000
  88: ThreadLocalAllocation.allocatedBytes = (Word) 0x000000000027d338 (2609976)
  96: VMThreads.IsolateTL = (Word) 0x00007fdbeec00000 (140582580125696)
  104: VMThreads.OSThreadHandleTL = (Word) 0x00007fe3eed0e740 (140616940971840)
  112: VMThreads.OSThreadIdTL = (Word) 0x00000000000097ea (38890)
  120: VMThreads.StackBase = (Word) 0x00007ffeb1ea8000 (140731883356160)
  128: VMThreads.StackEnd = (Word) 0x00007ffeb16a9000 (140731874971648)
  136: VMThreads.StartedByCurrentIsolate = (bytes) 0x0000000000000000
  144: VMThreads.nextTL = (Word) 0x0000000000000000 (0)
  152: VMThreads.unalignedIsolateThreadMemoryTL = (Word) 0x0000555e75e2b2e0 (93864193077984)
  160: ExceptionUnwind.currentException = (Object) 0x0000000000000000
  164: IsolatedCompileClient.currentClient = (Object) 0x0000000000000000
  168: IsolatedCompileContext.currentContext = (Object) 0x0000000000000000
  172: JNIObjectHandles.handles = (Object) 0x00007fdbf0880960
    is an object of type com.oracle.svm.core.handles.ThreadLocalHandles
  176: JNIThreadLocalPendingException.pendingException = (Object) 0x0000000000000000
  180: JNIThreadLocalReferencedObjects.referencedObjectsListHead = (Object) 0x0000000000000000
  184: JNIThreadOwnedMonitors.ownedMonitors = (Object) 0x0000000000000000
  188: NoAllocationVerifier.openVerifiers = (Object) 0x0000000000000000
  192: RecurringCallbackTimer.exception = (Object) 0x0000000000000000
  196: ThreadingSupportImpl.activeTimer = (Object) 0x0000000000000000
  200: ActionOnTransitionToJavaSupport.actionTL = (int) 0x00000000 (0)
  204: ImplicitExceptions.implicitExceptionsAreFatal = (int) 0x00000000 (0)
  208: StackOverflowCheckImpl.yellowZoneStateTL = (int) 0x7efefefe (2130640638)
  212: StatusSupport.safepointBehaviorTL = (int) 0x00000001 (1)
  216: ThreadingSupportImpl.currentPauseDepth = (int) 0x00000000 (0)
  
Java frame anchors for the failing thread 0x0000555e75e2b300:
  Anchor 0x00007ffeb1ea6a48 LastJavaSP 0x00007ffeb1ea6a30 LastJavaIP 0x0000555e703f2d2e
  
Stacktrace for the failing thread 0x0000555e75e2b300 (A=AOT compiled, J=JIT compiled, D=deoptimized, i=inlined):
  A  SP 0x00007ffeb1ea5980 IP 0x0000555e70363919 size=80    com.oracle.svm.core.code.IsolateEnterStub.JNIFunctions_FatalError_2d6e7de51007501356372d87ae0cc671dc9d1a91(IsolateEnterStub.java:0)
  i  SP 0x00007ffeb1ea6a30 IP 0x0000555e703f2d2e size=64    com.oracle.svm.core.jni.JNIOnLoadFunctionPointer.invoke(JNILibraryInitializer.java)
  A  SP 0x00007ffeb1ea6a30 IP 0x0000555e703f2d2e size=64    com.oracle.svm.core.jni.JNILibraryInitializer.callOnLoadFunction(JNILibraryInitializer.java:70)
  A  SP 0x00007ffeb1ea6a70 IP 0x0000555e703f2686 size=32    com.oracle.svm.core.jni.JNILibraryInitializer.initialize(JNILibraryInitializer.java:131)
  A  SP 0x00007ffeb1ea6a90 IP 0x0000555e703b487b size=96    com.oracle.svm.core.jdk.NativeLibrarySupport.addLibrary(NativeLibrarySupport.java:128)
  i  SP 0x00007ffeb1ea6af0 IP 0x0000555e703b3c33 size=48    com.oracle.svm.core.jdk.NativeLibrarySupport.addLibrary(NativeLibrarySupport.java:84)
  A  SP 0x00007ffeb1ea6af0 IP 0x0000555e703b3c33 size=48    com.oracle.svm.core.jdk.NativeLibraries.loadLibrary0(NativeLibraries.java:147)
  A  SP 0x00007ffeb1ea6b20 IP 0x0000555e703b3eaa size=80    com.oracle.svm.core.jdk.NativeLibraries.loadLibraryRelative(NativeLibraries.java:128)
  i  SP 0x00007ffeb1ea6b70 IP 0x0000555e70d08335 size=16    java.lang.ClassLoader.loadLibrary(ClassLoader.java:106)
  i  SP 0x00007ffeb1ea6b70 IP 0x0000555e70d08335 size=16    java.lang.Runtime.loadLibrary0(Runtime.java:916)
  i  SP 0x00007ffeb1ea6b70 IP 0x0000555e70d08335 size=16    java.lang.System.loadLibrary(System.java:2068)
  i  SP 0x00007ffeb1ea6b70 IP 0x0000555e70d08335 size=16    java.awt.Toolkit$2.run(Toolkit.java:1384)
  A  SP 0x00007ffeb1ea6b70 IP 0x0000555e70d08335 size=16    java.awt.Toolkit$2.run(Toolkit.java:1382)
  i  SP 0x00007ffeb1ea6b80 IP 0x0000555e70d0bbcd size=48    java.security.AccessController.executePrivileged(AccessController.java:128)
  i  SP 0x00007ffeb1ea6b80 IP 0x0000555e70d0bbcd size=48    java.security.AccessController.doPrivileged(AccessController.java:319)
  i  SP 0x00007ffeb1ea6b80 IP 0x0000555e70d0bbcd size=48    java.awt.Toolkit.loadLibraries(Toolkit.java:1381)
  i  SP 0x00007ffeb1ea6b80 IP 0x0000555e70d0bbcd size=48    java.awt.Toolkit.initStatic(Toolkit.java:1419)
  A  SP 0x00007ffeb1ea6b80 IP 0x0000555e70d0bbcd size=48    java.awt.Toolkit.<clinit>(Toolkit.java:1393)
  A  SP 0x00007ffeb1ea6bb0 IP 0x0000555e7035167d size=16    com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:408)
  A  SP 0x00007ffeb1ea6bc0 IP 0x0000555e70351529 size=32    com.oracle.svm.core.classinitialization.ClassInitializationInfo.doInitialize(ClassInitializationInfo.java:324)
  A  SP 0x00007ffeb1ea6be0 IP 0x0000555e70351f0c size=704   com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:273)
  A  SP 0x00007ffeb1ea6ea0 IP 0x0000555e70c9edee size=48    java.awt.Desktop.isDesktopSupported(Desktop.java:329)
  A  SP 0x00007ffeb1ea6ed0 IP 0x0000555e70c9d9b3 size=48    java.awt.Desktop.getDesktop(Desktop.java:303)
...
Threads:
  0x00007fdb94000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-102-acceptor-0@249e74a5-ServerConnector@4cf50424{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}" - 0x00007fdbf110dbb8, stack(0x00007fdbd8e02000,0x00007fdbd9601000)
  0x00007fdb98000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-101" - 0x00007fdbf110a7f0, stack(0x00007fdbd9802000,0x00007fdbda001000)
  0x00007fdba0000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-100" - 0x00007fdbf1104608, stack(0x00007fdbda202000,0x00007fdbdaa01000)
  0x00007fdba4000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-99" - 0x00007fdbf0ffdbc8, stack(0x00007fdbdac02000,0x00007fdbdb401000)
  0x00007fdbac000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-98" - 0x00007fdbf0ff7a10, stack(0x00007fdbdb602000,0x00007fdbdbe01000)
  0x00007fdbb0000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "Scheduler-1841001772-1" - 0x00007fdbf0ac2388, stack(0x00007fdbe4402000,0x00007fdbe4c01000)
  0x00007fdbb8000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-96" - 0x00007fdbf0a93450, stack(0x00007fdbe4e02000,0x00007fdbe5601000)
  0x00007fdbbc000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-95" - 0x00007fdbf0a92b58, stack(0x00007fdbe5802000,0x00007fdbe6001000)
  0x00007fdbc4000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-94" - 0x00007fdbf0a92288, stack(0x00007fdbe6202000,0x00007fdbe6a01000)
  0x00007fdbc8000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-93" - 0x00007fdbf0a919b8, stack(0x00007fdbe6c02000,0x00007fdbe7401000)
  0x00007fdbd4000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-91" - 0x00007fdbf0a907f0, stack(0x00007fdbec402000,0x00007fdbecc01000)
  0x00007fdbd0000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-92" - 0x00007fdbf0a910c0, stack(0x00007fdbe7602000,0x00007fdbe7e01000)
  0x00007fdbdc000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-90" - 0x00007fdbf0a8ff20, stack(0x00007fdbece02000,0x00007fdbed601000)
  0x00007fdbe0000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "qtp162148943-89" - 0x00007fdbf0a8f5e0, stack(0x00007fdbed802000,0x00007fdbee001000)
  0x00007fdbe8000b80 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "Reference Handler" - 0x00007fdbef9a19f0, daemon, stack(0x00007fdbee202000,0x00007fdbeea01000)
  0x0000555e75e2b300 STATUS_IN_JAVA (PREVENT_VM_FROM_REACHING_SAFEPOINT) "main" - 0x00007fdbef9a1a70, stack(0x00007ffeb16a9000,0x00007ffeb1ea8000)
  
No VMOperation in progress

The 30 most recent VM operation status changes:
  
VM mutexes:
  mutex "RealLog.backTracePrinterMutex" is unlocked.
  mutex "freeList" is unlocked.
  mutex "mainVMOperationControlWorkQueue" is unlocked.
  mutex "referencePendingList" is unlocked.
  mutex "thread" is unlocked.
  
Build time information:
  Version: 22.0.1+8, serial gc, compressed references
  Platform: linux/amd64
  Page size: 4096
  Container support: true
  CPU features used for AOT compiled code: CX8, CMOV, FXSR, MMX, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, POPCNT, LZCNT, AVX, AVX2, BMI1, BMI2, FMA, F16C
  
Runtime information:
  CPU cores (container): 32
  CPU cores (OS): 32
  Memory: 31205M
  Page size: 4096
  VM uptime: 0.010s
  Current timestamp: 1718715222667
  AOT compiled code: 0x0000555e6fec4000 - 0x0000555e726d776f
  
OS information:
  Max threads: 248922
  Max memory mappings: 65530
  Max PID: 4194304
  
Command line: '-server' 

Heap settings and statistics:
  Supports isolates: true
  Heap base: 0x00007fdbeec00000
  Object reference size: 4
  Reserved object header bits: 0b11111
  Aligned chunk size: 524288
  Large array threshold: 131072
  Incremental collections: 0
  Complete collections: 0
  
Heap usage:
  Eden: 10.50M (0.00M in 0 aligned chunks, 0.00M in 0 unaligned chunks)
  Old: 0.00M (0.00M in 0 aligned chunks, 0.00M in 0 unaligned chunks)
  
Native image heap boundaries:
  ReadOnly Primitives: 0x00007fdbeec80830 - 0x00007fdbef27ccd0
  ReadOnly References: 0x00007fdbef27ccd0 - 0x00007fdbef5e3058
  ReadOnly Relocatables: 0x00007fdbef5e4000 - 0x00007fdbef7d9410
  Writable Primitives: 0x00007fdbef7da000 - 0x00007fdbef901c50
  Writable References: 0x00007fdbef901c50 - 0x00007fdbefc42f48
  Writable Huge: 0x00007fdbefc80038 - 0x00007fdbefd34ce0
  ReadOnly Huge: 0x00007fdbefd35038 - 0x00007fdbf08686d8
  
Heap chunks: E=eden, S=survivor, O=old, F=free; A=aligned chunk, U=unaligned chunk; T=to space

@fernando-valdez
Copy link
Member

Hello,
Please share the exact version of GraalVM you used to get this crash.
Also, can you share a minimal reproducer that we can use to get the same crash locally?

@damnms
Copy link
Author

damnms commented Jun 20, 2024

graalvm-jdk-22.0.1+8.1
minimal reproducer

clone it, run ./gradlew nativeBuild, cd into the directory where the image is written to, e.g. "build/native/nativeCompile" and run ./graalvmcrash

@Karm
Copy link
Contributor

Karm commented Jun 25, 2024

Hello @damnms, @fernando-valdez,

I can confirm that if I do it manually:

import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class Application {

    public static void main(String args[]) throws URISyntaxException, IOException {
        Desktop.getDesktop().browse(new URI("http://localhost:8080"));
    }

}
$ javac Application.java
$ java -agentlib:native-image-agent=config-output-dir=AGENT Application
$ native-image -H:ConfigurationFileDirectories=./AGENT --no-fallback Application
$ ./application 

It works just fine, whereas if I use the Gradle native build mentioned in the reproducer, the resulting binary crashes. No, it's not *.so libs not being preset; they are correctly located next to the executable.

I'd say this is more about Gradle native build plugin and what it does to native-image though....

@Karm
Copy link
Contributor

Karm commented Jun 25, 2024

Using agent via the gradle plugin doesn't help either.

$ ./gradlew -Pagent run
$ ./gradlew nativeCompile

Both the crashing and the O.K. binaries go all the way to successfully loading libawt.so.
The O.K. one then proceeds and loads libawt_xawt.so whereas the failing one fails to do so. The error message is somewhat misleading.

@damnms
Copy link
Author

damnms commented Jun 25, 2024

so should i file this then against gradle resp. org.graalvm.buildtools.native?

@Karm
Copy link
Contributor

Karm commented Jun 25, 2024

@damnms @fernando-valdez
I think the case is resolved :) I just got confused as I have never used this gradle plugin before.

The crash is caused by the fact that C code need to call to Java call on java.lang.System to call load to load the next lib. This needs to be properly configured for native-image. The reason why it worked when I did it manually without Gradle and didn't with Gradle is that we both @damnms used the plugin incorrectly originally. Modified flow that works for me now:

$ export JAVA_HOME=/home/karm/X/JDKs/graalvm-community-openjdk-22.0.1+8.1/;export GRAALVM_HOME=${JAVA_HOME};export PATH=${JAVA_HOME}/bin:${PATH}
$ ./gradlew -Pagent run
$ ./gradlew metadataCopy --task run --dir src/main/resources/META-INF/native-image
$ ./gradlew nativeBuild
$ ./build/native/nativeCompile/graalvmcrash 

👍

@damnms
Copy link
Author

damnms commented Jun 25, 2024

thanks, unfortunately it does not work on my machine.

oli@DESKTOP-RA0V02P:~/IdeaProjects/graalvmcrash$ ./gradlew -Pagent run 

> Configure project :
Build file '/home/oli/IdeaProjects/graalvmcrash/build.gradle': line 33
The org.gradle.api.plugins.ApplicationPluginConvention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.8/userguide/upgrading_version_8.html#application_convention_deprecation
        at build_ce2o9pmxn90mewdh9c0cv23ge.run(/home/oli/IdeaProjects/graalvmcrash/build.gradle:33)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

> Task :run FAILED
[native-image-plugin] Instrumenting task with the native-image-agent: run
[0,038s][warning][jni,resolve] Re-registering of platform native method: jdk.internal.misc.Unsafe.allocateInstance(Ljava/lang/Class;)Ljava/lang/Object; from code in a different classloader
Exception in thread "main" java.lang.UnsupportedOperationException: The BROWSE action is not supported on the current platform!
        at java.desktop/java.awt.Desktop.checkActionSupport(Desktop.java:381)
        at java.desktop/java.awt.Desktop.browse(Desktop.java:531)
        at Application.main(Application.java:9)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/home/oli/Downloads/graalvm-jdk-22.0.1+8.1/bin/java'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 527ms
2 actionable tasks: 1 executed, 1 up-to-date

This should be handled in client code, not on compilation time, shouldnt it?
The problem behind this (the cause for the missing browse action) is another topic where i am still looking for a solution, seems like some of the .so are just messed af when running xfce on debian trixie

@Karm
Copy link
Contributor

Karm commented Jun 25, 2024

@damnms I ran it on CentOS 9 Stream, my laptop. Gnome on Wayland with X fallback.

Gimme your exact os specs and I can replicate it.

Sorry if I'm stating the obvious; if you are running a headless system, there won't be a browse action for awt...

@damnms
Copy link
Author

damnms commented Jun 25, 2024

i am running debian trixie with xfce

oli@DESKTOP-RA0V02P:~$ uname -a
Linux DESKTOP-RA0V02P 6.8.12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.8.12-1 (2024-05-31) x86_64 GNU/Linux
oli@DESKTOP-RA0V02P:~$ cat /proc/version 
Linux version 6.8.12-amd64 ([email protected]) (x86_64-linux-gnu-gcc-13 (Debian 13.2.0-25) 13.2.0, GNU ld (GNU Binutils for Debian) 2.42) #1 SMP PREEMPT_DYNAMIC Debian 6.8.12-1 (2024-05-31)

its not headless ;)

@Karm
Copy link
Contributor

Karm commented Jun 26, 2024

@damnms
Hmm, I replicated your env, deb trixie + xfce and I can see it too. The thing is though that this is coming from HotSpot, before native image comes into play. In fact, it's just a Java runtime thing. I can reproduce it with plain Temurin too, without anything GraalVM or native in play.

image

It seems that this piece fails to recognize gvfs and thus doesn't add BROWSE action capability:

https://github.com/openjdk/jdk22u/blob/jdk-22%2B36/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c#L160

It seems related to having XFCE. I checked and I do have gvfs installed.

I will poke around our of curiosity to see what would have to be changed for Debian or JDK to pick it up. Not a native-image issue though...

image

@Karm
Copy link
Contributor

Karm commented Jun 26, 2024

My GVFS and GTK3 with my JDK build on my CentOS 9 Stream, GNOME desktop, when it comes to this part of code reports these supported schemes:

KARM: Scheme: file
KARM: Scheme: smb
KARM: Scheme: mtp
KARM: Scheme: gphoto2
KARM: Scheme: google-drive
KARM: Scheme: trash
KARM: Scheme: sftp
KARM: Scheme: ssh
KARM: Scheme: recent
KARM: Scheme: network
KARM: Scheme: localtest
KARM: Scheme: http

@damnms Debian Trixie with XFCE Desktop shows this:

KARM: Scheme: file
KARM: Scheme: localtest
KARM: Scheme: burn
KARM: Scheme: computer
KARM: Scheme: trash
KARM: Scheme: resource

Note the missing http. When I skipped the check and enforced adding Action BROWSE as supported anyway, it worked, i.e Debian Trixie with XFCE normally opened Firefox window.

I did install various packages to get all the .so files I found with strace, e.g.

Apart from sort of barebone Mandrel/Graalvm dev set:

apt install g++ binutils make automake autoconf libtool gdb libc-devtools zlib1g-dev libfreetype-dev gcc  mc  vim zip unzip  git

I also installed gvfs-fuse strace libcanberra-gtk3-0 packagekit-gtk3-module so I do have these files on Debian now:

libgtk-3.so, libgvfsdbus.so, libgvfscommon.so, libcanberra-gtk-module.so, libpk-gtk-module.so and I even tried adding to LD_LIBRARY_PATH: /usr/lib/x86_64-linux-gnu/:/usr/lib/x86_64-linux-gnu/gio/modules/:/usr/lib/x86_64-linux-gnu/gvfs/:/usr/lib/x86_64-linux-gnu/gtk-3.0/modules/

To no avail, the http schema is still not listed there...

@Karm
Copy link
Contributor

Karm commented Jun 28, 2024

@damnms Uff. The package you need to install is: gvfs-backends And then it all gets to work :)

Case closed IMHO.

@damnms
Copy link
Author

damnms commented Jun 28, 2024

Wow, awesome! I am sure some will benefit from this finding! Thanks!!

@damnms damnms closed this as completed Jun 28, 2024
Karm added a commit to Karm/jdk that referenced this issue Jul 13, 2024
If there is problem with finding and calling e.g. java/awt/GraphicsEnvironment
in AWTIsHeadless, the env' Exception remains set and it not cleared.
Later, that manifests as:

    Fatal error reported via JNI: Could not allocate library name

Which is misleading. The code path is perhaps rare in normal JDK usage,
but it has been complicating our users' bug reports in the GraalVM/native-image
ecosystem for quite some time.

Instead of failing later with some clear message that indicates that the
user has incorrectly configured JNI, it bails out very soon with a message
that seems as if a jstring could not have been allocated. It sends users
on wild goose chases, e.g.

oracle/graal#9138
oracle/graal#8475
oracle/graal#9300
quarkusio/quarkus#31596
graalvm/mandrel#292
Karm/mandrel-integration-tests#262

This commit fixes the error reporting in the AWTIsHeadless.

Furthermore, when AOT compiled, there is little sense for having a JAVA_HOME,
yet some parts of AWT code look for it to search fonts. In such case, an
empty directory structure is enough to accommodate it, e.g.

/tmp/JAVA_HOME/
/tmp/JAVA_HOME/conf
/tmp/JAVA_HOME/conf/fonts
/tmp/JAVA_HOME/lib

The exception is somewhat cryptic for users again, merely stating:

    Exception in thread "main" java.io.IOException: Problem reading font data.
        at [email protected]/java.awt.Font.createFont0(Font.java:1205)
        at [email protected]/java.awt.Font.createFont(Font.java:1076)
        at imageio.Main.loadFonts(Main.java:139

Adding the cause there makes it clearer, i.e. that JAVA_HOME might be missing:

    Exception in thread "main" java.io.IOException: Problem reading font data.
        at java.desktop@23-internal/java.awt.Font.createFont0(Font.java:1206)
        at java.desktop@23-internal/java.awt.Font.createFont(Font.java:1076)
        at imageio.Main.loadFonts(Main.java:139)
        at imageio.Main.paintRectangles(Main.java:97)
        at imageio.Main.main(Main.java:195)
        at java.base@23-internal/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
    Caused by: java.lang.Error: java.home property not set
        at java.desktop@23-internal/sun.awt.FontConfiguration.findFontConfigFile(FontConfiguration.java:180)
        at java.desktop@23-internal/sun.awt.FontConfiguration.<init>(FontConfiguration.java:97)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants