oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.25k stars 1.62k forks source link

[GR-51419] Native Image crashes on Windows with jni native function #8085

Closed XUANXUQAQ closed 8 months ago

XUANXUQAQ commented 9 months ago

Describe the issue When the program call the jni native function with supplier object as parameter, it crashes. I've tried using trace agent to generate the jni config file and the reflect config file. native-image --no-fallback -jar JavaTest.jar

Steps to reproduce the issue

  1. git clone --depth 1 https://github.com/XUANXUQAQ/native-image-crash-reproducer.git
  2. Build the JAR artifact using Intellij idea with dependencies included
  3. Use Visual Studio to compile Test\Test.sln and get Test.dll, which is already contained in the repository
  4. Compile the jar package to native image, and put Test.dll at the same folder, run compiled exe

Describe GraalVM and your environment:

More details

native image building output:
Apply jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/jni-config.json
Apply jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/reflect-config.json
Apply jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/resource-config.json
Apply jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/proxy-config.json
Apply jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/serialization-config.json
Apply jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/predefined-classes-config.json
Apply jar:file:///C:/Users/user/Downloads/graalvm-community-openjdk-21.0.1+12.1/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/thirdparty/native-image.properties
Apply jar:file:///C:/Users/user/Downloads/graalvm-community-openjdk-21.0.1+12.1/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/polyglot/native-image.properties
Executing [
'INCLUDE=D:\windows-software\Visual Studio\VC\Tools\MSVC\14.38.33130\include;D:\windows-software\Visual Studio\VC\Tools\MSVC\14.38.33130\ATLMFC\include;D:\windows-software\Visual Studio\VC\Auxiliary\VS\include;D:\Windows Kits\10\include\10.0.22621.0\ucrt;D:\Windows Kits\10\\include\10.0.22621.0\\um;D:\Windows Kits\10\\include\10.0.22621.0\\shared;D:\Windows Kits\10\\include\10.0.22621.0\\winrt;D:\Windows Kits\10\\include\10.0.22621.0\\cppwinrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um' \
'LIB=D:\windows-software\Visual Studio\VC\Tools\MSVC\14.38.33130\ATLMFC\lib\x64;D:\windows-software\Visual Studio\VC\Tools\MSVC\14.38.33130\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64;D:\Windows Kits\10\lib\10.0.22621.0\ucrt\x64;D:\Windows Kits\10\\lib\10.0.22621.0\\um\x64' \
'Path=D:\windows-software\Visual Studio\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64;D:\windows-software\Visual Studio\Common7\IDE\VC\VCPackages;D:\windows-software\Visual Studio\Common7\IDE\CommonExtensions\Microsoft\TestWindow;D:\windows-software\Visual Studio\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;D:\windows-software\Visual Studio\MSBuild\Current\bin\Roslyn;D:\windows-software\Visual Studio\Team Tools\Performance Tools\x64;D:\windows-software\Visual Studio\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\HTML Help Workshop;D:\windows-software\Visual Studio\Common7\IDE\CommonExtensions\Microsoft\FSharp\Tools;D:\windows-software\Visual Studio\Team Tools\DiagnosticsHub\Collector;D:\Windows Kits\10\bin\10.0.22621.0\\x64;D:\Windows Kits\10\bin\\x64;D:\windows-software\Visual Studio\\MSBuild\Current\Bin\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;D:\windows-software\Visual Studio\Common7\IDE\;D:\windows-software\Visual Studio\Common7\Tools\;D:\windows-software\anaconda\condabin;D:\windows-software\zulu17-jdk\bin\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\windows-software\nodejs\;D:\windows-software\Go-Programming\bin;C:\Program Files\WireGuard\;C:\Windows\System32\OpenSSH;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\dotnet\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2022.4.1\;D:\windows-software\Git\cmd;D:\windows-software\easyshare\x86\;D:\windows-software\easyshare\x64\;C:\Users\user\AppData\Local\pnpm;D:\windows-software\rust\cargo_home\bin;C:\Users\user\AppData\Local\Microsoft\WindowsApps;D:\windows-software\IntelliJ IDEA\bin;D:\windows-software\Microsoft VS Code\bin;D:\windows-software\JetBrains Rider\bin;D:\windows-software\Git\bin;D:\windows-software\bandzip\;D:\windows-software\adb;D:\windows-software\npm;D:\windows-software\DataGrip\bin;D:\windows-software\rust\rust_home;D:\windows-software\rust\cargo_home;C:\Users\user\go\bin;D:\windows-software\apache-maven\bin;C:\Users\user\.dotnet\tools;D:\windows-software\vcpkg;C:\Program Files\Azure Data Studio\bin;C:\Users\user\AppData\Local\JetBrains\Toolbox\scripts;C:\Users\user\AppData\Roaming\npm;C:\Users\user\go\bin;D:\windows-software\ForceBindIP;D:\windows-software\anaconda\Scripts;D:\windows-software\anaconda\Library\bin;D:\windows-software\anaconda;C:\Users\user\.dotnet\tools;D:\windows-software\Visual Studio\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;D:\windows-software\Visual Studio\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja;D:\windows-software\Visual Studio\Common7\IDE\VC\Linux\bin\ConnectionManagerExe' \
'TEMP=D:\Temps\Temp' \
USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM=true \
'C:\Users\user\Downloads\graalvm-community-openjdk-21.0.1+12.1\bin\java.exe' \
-XX:+UseParallelGC \
-XX:+UnlockExperimentalVMOptions \
-XX:+EnableJVMCI \
-Dtruffle.TrustAllTruffleRuntimeProviders=true \
-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime \
-Dgraalvm.ForcePolyglotInvalid=true \
-Dgraalvm.locatorDisabled=true \
--add-exports=java.base/com.sun.crypto.provider=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.access=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.event=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.loader=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.logger=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.misc=org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto \
--add-exports=java.base/jdk.internal.module=org.graalvm.nativeimage.base,org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.org.objectweb.asm=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.perf=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.platform=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.ref=org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile \
--add-exports=java.base/jdk.internal.reflect=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.util=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.vm.annotation=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal.vm=org.graalvm.nativeimage.builder \
--add-exports=java.base/jdk.internal=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.invoke.util=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.net.www=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.net=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.nio.ch=org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile \
--add-exports=java.base/sun.reflect.annotation=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.reflect.generics.factory=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.reflect.generics.reflectiveObjects=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.reflect.generics.repository=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.reflect.generics.scope=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.reflect.generics.tree=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.security.jca=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.security.provider=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.security.ssl=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.security.util=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.security.x509=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.text.spi=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.util.calendar=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.util.cldr=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.util.locale.provider=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.util.locale=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.util.resources=org.graalvm.nativeimage.builder \
--add-exports=java.base/sun.util=org.graalvm.nativeimage.builder \
--add-exports=java.management/com.sun.jmx.mbeanserver=org.graalvm.nativeimage.builder \
--add-exports=java.management/sun.management=org.graalvm.nativeimage.builder,org.graalvm.nativeimage.pointsto \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=jdk.graal.compiler,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=jdk.graal.compiler,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=jdk.graal.compiler,org.graalvm.nativeimage.builder \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=jdk.graal.compiler,org.graalvm.nativeimage.builder \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=jdk.graal.compiler,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto,org.graalvm.truffle.compiler \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=jdk.graal.compiler,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.pointsto \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=jdk.graal.compiler \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=jdk.graal.compiler \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.riscv64=jdk.graal.compiler \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=jdk.graal.compiler,org.graalvm.nativeimage.builder \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=jdk.graal.compiler,org.graalvm.nativeimage.base,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto,org.graalvm.truffle.compiler \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.riscv64=jdk.graal.compiler,org.graalvm.nativeimage.builder \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=jdk.graal.compiler,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.pointsto \
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=jdk.graal.compiler,org.graalvm.nativeimage.builder \
--add-exports=jdk.jfr/jdk.jfr.events=org.graalvm.nativeimage.builder \
--add-exports=jdk.jfr/jdk.jfr.internal.event=org.graalvm.nativeimage.builder \
--add-exports=jdk.jfr/jdk.jfr.internal.jfc=org.graalvm.nativeimage.builder \
--add-exports=jdk.jfr/jdk.jfr.internal=org.graalvm.nativeimage.builder \
--add-exports=jdk.management/com.sun.management.internal=org.graalvm.nativeimage.builder \
-XX:+UseJVMCINativeLibrary \
-Xss10m \
-XX:MaxRAMPercentage=60.301891956128415 \
-XX:GCTimeRatio=9 \
-XX:+ExitOnOutOfMemoryError \
-Djava.awt.headless=true \
'-Dorg.graalvm.vendor=GraalVM Community' \
-Dorg.graalvm.vendorurl=https://www.graalvm.org/ \
'-Dorg.graalvm.vendorversion=GraalVM CE 21.0.1-dev+12.1' \
-Dorg.graalvm.version=24.0.0-dev \
-Dcom.oracle.graalvm.isaot=true \
-Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader \
-Xshare:off \
-Djdk.reflect.useOldSerializableConstructor=true \
-Djdk.internal.lambda.disableEagerInitialization=true \
-Djdk.internal.lambda.eagerlyInitialize=false \
-Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false \
--add-modules=ALL-DEFAULT \
--module-path \
'C:\Users\user\Downloads\graalvm-community-openjdk-21.0.1+12.1\lib\svm\builder\native-image-base.jar;C:\Users\user\Downloads\graalvm-community-openjdk-21.0.1+12.1\lib\svm\builder\objectfile.jar;C:\Users\user\Downloads\graalvm-community-openjdk-21.0.1+12.1\lib\svm\builder\pointsto.jar;C:\Users\user\Downloads\graalvm-community-openjdk-21.0.1+12.1\lib\svm\builder\svm.jar' \
--module \
org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner \
-keepalive \
'D:\Temps\Temp\.native_image17733412006604442126alive' \
-imagecp \
'D:\Windows-code\JavaTest\out\artifacts\JavaTest_jar\JavaTest.jar' \
-imagemp \
'C:\Users\user\Downloads\graalvm-community-openjdk-21.0.1+12.1\lib\svm\library-support.jar' \
'-H:CLibraryPath=C:\Users\user\Downloads\graalvm-community-openjdk-21.0.1+12.1\lib\svm\clibraries\windows-amd64' \
'-H:Path@driver=D:\Windows-code\JavaTest\out\artifacts\JavaTest_jar' \
-H:FallbackThreshold@user+api=0 \
-H:+DumpTargetInfo@user+api \
'-H:Name@manifest from file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar=JavaTest' \
'-H:Class@manifest from file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar=Main' \
'-H:JNIConfigurationResources@jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/jni-config.json+api=META-INF/native-image/jni-config.json' \
'-H:ReflectionConfigurationResources@jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/reflect-config.json+api=META-INF/native-image/reflect-config.json' \
'-H:ResourceConfigurationResources@jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/resource-config.json+api=META-INF/native-image/resource-config.json' \
'-H:DynamicProxyConfigurationResources@jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/proxy-config.json+api=META-INF/native-image/proxy-config.json' \
'-H:SerializationConfigurationResources@jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/serialization-config.json+api=META-INF/native-image/serialization-config.json' \
'-H:PredefinedClassesConfigurationResources@jar:file:///D:/Windows-code/JavaTest/out/artifacts/JavaTest_jar/JavaTest.jar!/META-INF/native-image/predefined-classes-config.json+api=META-INF/native-image/predefined-classes-config.json' \
-H:ImageBuildID@driver=72967845-dd96-0909-8ce2-8b4a06828d3c \
'-H:Features@jar:file:///C:/Users/user/Downloads/graalvm-community-openjdk-21.0.1+12.1/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/thirdparty/native-image.properties+api=com.oracle.svm.thirdparty.gson.GsonFeature' \
'-H:Features@jar:file:///C:/Users/user/Downloads/graalvm-community-openjdk-21.0.1+12.1/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/polyglot/native-image.properties+api=com.oracle.svm.polyglot.groovy.GroovyIndyInterfaceFeature,com.oracle.svm.polyglot.scala.ScalaFeature'
]
========================================================================================================================
GraalVM Native Image: Generating 'JavaTest' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------
[1/8] Initializing...                                                                                    (6.1s @ 0.18GB)
 Java version: 21.0.1+12, vendor version: GraalVM CE 21.0.1-dev+12.1
 Graal compiler: optimization level: 2, target machine: x86-64-v3
 C compiler: cl.exe (microsoft, x64, 19.38.33133)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 1 user-specific feature(s):
 - com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
Build resources:
 - 21.13GB of memory (53.6% of 39.42GB system memory, determined at start)
 - 16 thread(s) (100.0% of 16 available processor(s), determined at start)
# Printing compilation-target information to: D:\Windows-code\JavaTest\out\artifacts\JavaTest_jar\reports\target_info_20231222_224035.txt
# Printing native-library information to: D:\Windows-code\JavaTest\out\artifacts\JavaTest_jar\reports\native_library_info_20231222_224044.txt
[2/8] Performing analysis...  [****]                                                                     (9.3s @ 0.35GB)
    3,247 reachable types   (73.5% of    4,419 total)
    3,817 reachable fields  (42.6% of    8,967 total)
   15,834 reachable methods (46.3% of   34,164 total)
    1,094 types,    84 fields, and   691 methods registered for reflection
       61 types,    51 fields, and    52 methods registered for JNI access
        1 native library: version
[3/8] Building universe...                                                                               (1.5s @ 0.36GB)
[4/8] Parsing methods...      [*]                                                                        (0.7s @ 0.36GB)
[5/8] Inlining methods...     [***]                                                                      (0.6s @ 0.42GB)
[6/8] Compiling methods...    [***]                                                                      (8.0s @ 0.33GB)
[7/8] Laying out methods...   [*]                                                                        (1.1s @ 0.40GB)
[8/8] Creating image...       [*]                                                                        (1.6s @ 0.33GB)
   5.59MB (40.56%) for code area:     9,071 compilation units
   8.02MB (58.24%) for image heap:  101,995 objects and 103 resources
 170.11kB ( 1.21%) for other data
  13.78MB in total
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area:                                Top 10 object types in image heap:
   4.13MB java.base                                            1.64MB byte[] for code metadata
   1.06MB svm.jar (Native Image)                               1.34MB byte[] for java.lang.String
 112.83kB java.logging                                      1020.94kB java.lang.String
  64.40kB org.graalvm.nativeimage.base                       772.79kB java.lang.Class
  47.59kB jdk.proxy1                                         369.35kB byte[] for general heap data
  45.84kB jdk.proxy3                                         279.04kB com.oracle.svm.core.hub.DynamicHubCompanion
  26.95kB jdk.internal.vm.ci                                 257.32kB heap alignment
  22.42kB org.graalvm.collections                            251.86kB java.util.HashMap$Node
  11.42kB jdk.proxy2                                         225.28kB java.lang.Object[]
   8.10kB jdk.graal.compiler                                 205.36kB java.lang.String[]
   4.78kB for 3 more packages                                  1.74MB for 931 more object types
------------------------------------------------------------------------------------------------------------------------
Recommendations:
 HEAP: Set max heap for improved and more predictable memory usage.
 CPU:  Enable more CPU features with '-march=native' for improved performance.
------------------------------------------------------------------------------------------------------------------------
                        1.4s (4.7% of total time) in 184 GCs | Peak RSS: 0.93GB | CPU load: 9.85
------------------------------------------------------------------------------------------------------------------------
Produced artifacts:
 D:\Windows-code\JavaTest\out\artifacts\JavaTest_jar\JavaTest.exe (executable)
========================================================================================================================
Finished generating 'JavaTest' in 29.8s.

Crash report:


[ [ SegfaultHandler caught a segfault in thread 0x000002500942ad00 ] ]
siginfo: ExceptionCode: -1073741819, reading address 0x0000025009600040 (heapBase + 64)
General purpose register values:
  RAX 0x0000025009600000 is the heap base
  RBX 0x00000001006c29c0 is an unknown value
  RCX 0x000002500942ad00 is a thread
  RDX 0x00000001006c29c0 is an unknown value
  RBP 0x0000000000000000
  RSI 0x000002500942ad00 is a thread
  RDI 0x00000001003d6698 is an unknown value
  RSP 0x000000b41beffbd8 points into the stack for thread 0x000002500942ad00
  R8  0x0000000000000000
  R9  0x000000b41beffc28 points into the stack for thread 0x000002500942ad00
  R10 0x0000025009600000 is the heap base
  R11 0x000002500942ad00 is a thread
  R12 0x00007ff6a7ef158b points into AOT compiled code NativeTest.nativeFunc(Native Method)
  R13 0x000000b41beffc78 points into the stack for thread 0x000002500942ad00
  R14 0x0000025009600000 is the heap base
  R15 0x000002500942ad00 is a thread
  EFL 0x0000000000010206 is an unknown value
  RIP 0x00007ff6a7f871ca points into AOT compiled code com.oracle.svm.core.jni.JNIJavaCallTrampolineHolder.valistJavaCallTrampoline(JNIJavaCallTrampolineHolder.java)

Printing instructions (ip=0x00007ff6a7f871ca):
  0x00007ff6a7f870ca: 0x89 0x54 0x24 0x18 0x66 0x90 0xe8 0x6b 0x3b 0xfe 0xff 0x90 0x48 0x89 0x74 0x24
  0x00007ff6a7f870da: 0x30 0x89 0x7c 0x24 0x2c 0x48 0x89 0x54 0x24 0x18 0xe8 0x67 0x9a 0x06 0x00 0x90
  0x00007ff6a7f870ea: 0x48 0x8b 0xc2 0x48 0xba 0x18 0xf8 0x28 0x00 0x00 0x00 0x00 0x00 0x49 0x8d 0x14
  0x00007ff6a7f870fa: 0x16 0xe8 0xe0 0x89 0x06 0x00 0x90 0x48 0x8b 0xd0 0x48 0x8b 0xca 0x48 0x81 0xe1
  0x00007ff6a7f8710a: 0x00 0x00 0xf8 0xff 0x48 0x8d 0x99 0x30 0x08 0x00 0x00 0x48 0x2b 0xd3 0x48 0xc1
  0x00007ff6a7f8711a: 0xea 0x09 0x80 0x7c 0x11 0x30 0x00 0x0f 0x84 0x56 0xff 0xff 0xff 0xc6 0x44 0x11
  0x00007ff6a7f8712a: 0x30 0x00 0x0f 0x1f 0x40 0x00 0xe9 0x48 0xff 0xff 0xff 0x48 0x8b 0xd0 0x48 0x8b
  0x00007ff6a7f8713a: 0xca 0x48 0x81 0xe1 0x00 0x00 0xf8 0xff 0x48 0x8d 0x99 0x30 0x08 0x00 0x00 0x48
  0x00007ff6a7f8714a: 0x2b 0xd3 0x48 0xc1 0xea 0x09 0x80 0x7c 0x11 0x30 0x00 0x0f 0x84 0x42 0xff 0xff
  0x00007ff6a7f8715a: 0xff 0xc6 0x44 0x11 0x30 0x00 0xe9 0x38 0xff 0xff 0xff 0x48 0x8b 0xd0 0x48 0x8b
  0x00007ff6a7f8716a: 0xca 0x48 0x81 0xe1 0x00 0x00 0xf8 0xff 0x48 0x8d 0x99 0x30 0x08 0x00 0x00 0x48
  0x00007ff6a7f8717a: 0x2b 0xd3 0x48 0xc1 0xea 0x09 0x80 0x7c 0x11 0x30 0x00 0x0f 0x84 0xd2 0xfe 0xff
  0x00007ff6a7f8718a: 0xff 0xc6 0x44 0x11 0x30 0x00 0xe9 0xc8 0xfe 0xff 0xff 0xe8 0xb6 0x0f 0xfd 0xff
  0x00007ff6a7f8719a: 0x90 0xe9 0xa1 0xfe 0xff 0xff 0x48 0x8b 0x81 0xb8 0x00 0x00 0x00 0x49 0x03 0xc0
  0x00007ff6a7f871aa: 0xff 0x60 0x38 0xcc 0xcc 0xcc 0x48 0x8b 0x81 0xb8 0x00 0x00 0x00 0x49 0x03 0xc1
  0x00007ff6a7f871ba: 0xff 0x60 0x50 0xcc 0xcc 0xcc 0x48 0x8b 0x81 0xb8 0x00 0x00 0x00 0x49 0x03 0xc0
> 0x00007ff6a7f871ca: 0xff 0x60 0x40 0xcc 0xcc 0xcc 0x48 0x8b 0x81 0xb8 0x00 0x00 0x00 0x49 0x03 0xc1
  0x00007ff6a7f871da: 0xff 0x60 0x58 0xcc 0xcc 0xcc 0x48 0x8b 0x81 0xb8 0x00 0x00 0x00 0x49 0x03 0xc0
  0x00007ff6a7f871ea: 0xff 0x60 0x30 0xcc 0xcc 0xcc 0x48 0x8b 0x81 0xb8 0x00 0x00 0x00 0x49 0x03 0xc1
  0x00007ff6a7f871fa: 0xff 0x60 0x48 0xcc 0xcc 0xcc 0x48 0x81 0xec 0xc8 0x01 0x00 0x00 0x4d 0x8b 0xd6
  0x00007ff6a7f8720a: 0x4d 0x8b 0xdf 0x48 0x8b 0xc5 0x48 0x89 0x8c 0x24 0xc0 0x01 0x00 0x00 0x4c 0x89
  0x00007ff6a7f8721a: 0x8c 0x24 0xb8 0x01 0x00 0x00 0x48 0x85 0xc9 0x0f 0x84 0xc7 0x01 0x00 0x00 0x4c
  0x00007ff6a7f8722a: 0x8b 0xf9 0x4c 0x8b 0x89 0xb8 0x00 0x00 0x00 0x4d 0x8b 0xf1 0x66 0x66 0x0f 0x1f
  0x00007ff6a7f8723a: 0x84 0x00 0x00 0x00 0x00 0x00 0x41 0x83 0xbf 0xf8 0x00 0x00 0x00 0x00 0x0f 0x85
  0x00007ff6a7f8724a: 0xaf 0x01 0x00 0x00 0x48 0x89 0x84 0x24 0xb0 0x01 0x00 0x00 0xb8 0x03 0x00 0x00
  0x00007ff6a7f8725a: 0x00 0xb9 0x01 0x00 0x00 0x00 0xf0 0x41 0x0f 0xb1 0x4f 0x14 0x0f 0x85 0xb9 0x02
  0x00007ff6a7f8726a: 0x00 0x00 0x49 0x8b 0xc0 0x49 0x03 0xc6 0x48 0x89 0x44 0x24 0x10 0x49 0x3b 0xc6
  0x00007ff6a7f8727a: 0x0f 0x84 0x1a 0x03 0x00 0x00 0xc5 0x7e 0x7f 0xbc 0x24 0x90 0x01 0x00 0x00 0xc5
  0x00007ff6a7f8728a: 0x7e 0x7f 0xb4 0x24 0x70 0x01 0x00 0x00 0xc5 0x7e 0x7f 0xac 0x24 0x50 0x01 0x00
  0x00007ff6a7f8729a: 0x00 0xc5 0x7e 0x7f 0xa4 0x24 0x30 0x01 0x00 0x00 0xc5 0x7e 0x7f 0x9c 0x24 0x10
  0x00007ff6a7f872aa: 0x01 0x00 0x00 0xc5 0x7e 0x7f 0x94 0x24 0xf0 0x00 0x00 0x00 0xc5 0x7e 0x7f 0x8c
  0x00007ff6a7f872ba: 0x24 0xd0 0x00 0x00 0x00 0xc5 0x7e 0x7f 0x84 0x24 0xb0 0x00 0x00 0x00 0xc5 0xfe

Top of stack (sp=0x000000b41beffbd8):
  0x000000b41beffbb8: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
> 0x000000b41beffbd8: 0x00007ffc7898108c 0x0000000000000000 0x0000000000000000 0x00007ffc789810b0
  0x000000b41beffbf8: 0x00007ff6a7f911cd 0x00000001003d6698 0x00007ffc78981100 0x0000001000000000
  0x000000b41beffc18: 0x00007ff6a7f8eaf5 0x0000000000000000 0x000000b41beff630 0x000000000000000a
  0x000000b41beffc38: 0x00007ff6a7ef159e 0x0000000000000004 0x00000000003efd10 0x0000000000000010
  0x000000b41beffc58: 0xfbe7fcfbd8000006 0x0000000000000000 0x0000025009f058f8 0x0000025009cc29c0
  0x000000b41beffc78: 0x00007ff6a7ef158b 0x000000b41beffc40 0x0000000000000000 0x0000000000000004
  0x000000b41beffc98: 0x00007ffc789810b0 0x0000000109bcdfc8 0x00007ff6a7ef10a5 0x0000025009ab5af0
  0x000000b41beffcb8: 0x00007ff6a7f034a6 0x0000000100000000 0x00007ff6a7f0326d 0x00720061006a005f
  0x000000b41beffcd8: 0x00760061004a005c 0x0073006500540061 0x00780065002e0074 0x00007ff6a849f858
  0x000000b41beffcf8: 0x0000025009438970 0x000000010000000d 0x00007ff6a7f35d77 0x000002500942ab40
  0x000000b41beffd18: 0x00007ffc00000017 0x0000025009438970 0x0000000109438680 0x0000000000000000
  0x000000b41beffd38: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x000000b41beffd58: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x000000b41beffd78: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x000000b41beffd98: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000
  0x000000b41beffdb8: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000

VM thread locals for the failing thread 0x000002500942ad00:
  0: JNIThreadLocalEnvironment.jniFunctions = (bytes) 0x0000025009992010
  8: StackOverflowCheckImpl.stackBoundaryTL = (Word) 0x0000000000000001 (1)
  16: Safepoint.safepointRequested = (int) 0x7fff73c7 (2147447751)
  20: StatusSupport.statusTL = (int) 0x00000001 (1)
  24: ThreadLocalAllocation.regularTLAB = (bytes)
    0x000002500942ad18: 0x0000025009f00000 0x0000025009f80000
    0x000002500942ad28: 0x0000025009f071d8 0x0000000000000000
  56: PlatformThreads.currentThread = (Object) 0x0000025009b4c598
    is an object of type java.lang.Thread
  64: JavaFrameAnchors.lastAnchor = (Word) 0x000000b41beffc78 (773562825848)
  72: JavaThreads.currentVThreadId = (long) 0x0000000000000001 (1)
  80: ExceptionUnwind.currentException = (Object) 0x0000000000000000
  88: IdentityHashCodeSupport.hashCodeGeneratorTL = (Object) 0x0000000000000000
  96: IsolatedCompileClient.currentClient = (Object) 0x0000000000000000
  104: IsolatedCompileContext.currentContext = (Object) 0x0000000000000000
  112: JNIObjectHandles.handles = (Object) 0x0000025009f009c0
    is an object of type com.oracle.svm.core.handles.ThreadLocalHandles
  120: JNIThreadLocalPendingException.pendingException = (Object) 0x0000025009f06ea8
    is an object of type java.lang.NoSuchMethodError: Main$$Lambda/0x9df0f17e30e96ad34951ee937da55a7bd745af7a0.get()Ljava/lang/Object;
        at com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1347)
        at com.oracle.svm.core.jni.functions.JNIFunctions$Support.getMethodID(JNIFunctions.java:1332)
        ... 4 more
  128: JNIThreadLocalReferencedObjects.referencedObjectsListHead = (Object) 0x0000000000000000
  136: JNIThreadOwnedMonitors.ownedMonitors = (Object) 0x0000000000000000
  144: NoAllocationVerifier.openVerifiers = (Object) 0x0000000000000000
  152: RecurringCallbackTimer.exception = (Object) 0x0000000000000000
  160: ThreadingSupportImpl.activeTimer = (Object) 0x0000000000000000
  168: SubstrateDiagnostics.threadOnlyAttachedForCrashHandler = (bytes) 0x0000000000000000
  176: ThreadLocalAllocation.allocatedBytes = (Word) 0x0000000000000000 (0)
  184: VMThreads.IsolateTL = (Word) 0x0000025009600000 (2542777925632)
  192: VMThreads.OSThreadHandleTL = (Word) 0x00000000000000cc (204)
  200: VMThreads.OSThreadIdTL = (Word) 0x000000000000390c (14604)
  208: VMThreads.StackBase = (Word) 0x000000b41bf00000 (773562826752)
  216: VMThreads.StackEnd = (Word) 0x000000b41be00000 (773561778176)
  224: VMThreads.StartedByCurrentIsolate = (bytes) 0x0000000000000000
  232: VMThreads.nextTL = (Word) 0x0000000000000000 (0)
  240: VMThreads.unalignedIsolateThreadMemoryTL = (Word) 0x000002500942ace0 (2542776003808)
  248: ActionOnTransitionToJavaSupport.actionTL = (int) 0x00000000 (0)
  252: ImplicitExceptions.implicitExceptionsAreFatal = (int) 0x00000000 (0)
  256: StackOverflowCheckImpl.yellowZoneStateTL = (int) 0x7efefefe (2130640638)
  260: StatusSupport.safepointBehaviorTL = (int) 0x00000001 (1)
  264: ThreadingSupportImpl.currentPauseDepth = (int) 0x00000000 (0)

Java frame anchors for the failing thread 0x000002500942ad00:
  Anchor 0x000000b41beffc78 LastJavaSP 0x000000b41beffc40 LastJavaIP 0x00007ff6a7ef158b

Stacktrace for the failing thread 0x000002500942ad00 (A=AOT compiled, J=JIT compiled, D=deoptimized, i=inlined):
  A  SP 0x000000b41beffbd8 IP 0x00007ff6a7f871ca size=8     com.oracle.svm.core.jni.JNIJavaCallTrampolineHolder.valistJavaCallTrampoline(JNIJavaCallTrampolineHolder.java)
  SP 0x000000b41beffbe0 IP 0x00007ffc7898108c  IP is not within Java code. Aborting stack trace printing.

  Warning: stack pointer is not aligned to 16 bytes.

  Starting the stack walk in a possible caller (sp + 40):
  A  SP 0x000000b41beffc00 IP 0x00007ff6a7f911cd size=64    com.oracle.svm.core.jni.access.JNINativeLinkage.getOrFindEntryPoint(JNINativeLinkage.java:147)
  A  SP 0x000000b41beffc40 IP 0x00007ff6a7ef159e size=112   NativeTest.nativeFunc(Native Method)
  A  SP 0x000000b41beffcb0 IP 0x00007ff6a7ef10a5 size=16    Main.main(Main.java:3)
  i  SP 0x000000b41beffcc0 IP 0x00007ff6a7f034a6 size=16    java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
  i  SP 0x000000b41beffcc0 IP 0x00007ff6a7f034a6 size=16    com.oracle.svm.core.JavaMainWrapper.invokeMain(JavaMainWrapper.java:180)
  A  SP 0x000000b41beffcc0 IP 0x00007ff6a7f034a6 size=16    com.oracle.svm.core.JavaMainWrapper.runCore0(JavaMainWrapper.java:233)
  i  SP 0x000000b41beffcd0 IP 0x00007ff6a7f0326d size=64    com.oracle.svm.core.JavaMainWrapper.runCore(JavaMainWrapper.java:200)
  A  SP 0x000000b41beffcd0 IP 0x00007ff6a7f0326d size=64    com.oracle.svm.core.JavaMainWrapper.doRun(JavaMainWrapper.java:289)
  i  SP 0x000000b41beffd10 IP 0x00007ff6a7f35d77 size=448   com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:275)
  A  SP 0x000000b41beffd10 IP 0x00007ff6a7f35d77 size=448   com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_5087f5482cc9a6abc971913ece43acb471d2631b(IsolateEnterStub.java:0)

Threads:
  0x000002500943e4c0 STATUS_IN_NATIVE (ALLOW_SAFEPOINT) "Reference Handler" - 0x0000025009b4c650, daemon, stack(0x000000b41c200000,0x000000b41c300000)
  0x000002500942ad00 STATUS_IN_JAVA (PREVENT_VM_FROM_REACHING_SAFEPOINT) "main" - 0x0000025009b4c598, stack(0x000000b41be00000,0x000000b41bf00000)

No VMOperation in progress

The 30 most recent VM operation status changes:

VM mutexes:
  mutex "mainVMOperationControlWorkQueue" is unlocked.
  mutex "thread" is unlocked.
  mutex "referencePendingList" is unlocked.
  mutex "RealLog.backTracePrinterMutex" is unlocked.

Build time information:
  Version: 21.0.1+12, serial gc
  Platform: windows/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): unknown
  CPU cores (OS): 16
  Memory: 40364M
  Page size: 4096
  VM uptime: 0.091s
  Current timestamp: 1703256107270
  AOT compiled code: 0x00007ff6a7ef1000 - 0x00007ff6a848778f

Command line:

Heap settings and statistics:
  Supports isolates: true
  Heap base: 0x0000025009600000
  Object reference size: 8
  Reserved object header bits: 0b111
  Aligned chunk size: 524288
  Large array threshold: 131072
  Incremental collections: 0
  Complete collections: 0

Heap usage:
  Eden: 0.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: 0x0000025009680830 - 0x00000250098218e8
  ReadOnly References: 0x00000250098218e8 - 0x0000025009991c10
  ReadOnly Relocatables: 0x0000025009992000 - 0x0000025009a23a78
  Writable Primitives: 0x0000025009a24000 - 0x0000025009ae5980
  Writable References: 0x0000025009ae5980 - 0x0000025009cc74a0
  Writable Huge: 0x0000000000000000 - 0x0000000000000000
  ReadOnly Huge: 0x0000025009d00038 - 0x0000025009e85130

Heap chunks: E=eden, S=survivor, O=old, F=free; A=aligned chunk, U=unaligned chunk; T=to space

Segfault detected, aborting process. Use '-XX:-InstallSegfaultHandler' to disable the segfault handler at run time and create a core dump instead. Rebuild with '-R:-InstallSegfaultHandler' to disable the handler permanently at build time.
wirthi commented 8 months ago

Thanks for reporting this issue, we are investigating.

wirthi commented 8 months ago

Hi @XUANXUQAQ

this is most likely a bug in your application. In https://github.com/XUANXUQAQ/native-image-crash-reproducer/blob/1c94b622393df9ce85cbc9e426642ad0f26f938e/Test/dllmain.cpp#L30C5-L30C100 you are querying a method and then call it immediately without checking for an error first. The crash is basically hinting that you call a NULL value here, so you need to check for that before calling.

The reason for the unexpected NULL value might be, that you are missing the configuration metadata required for JNI when building a native image, see https://www.graalvm.org/latest/reference-manual/native-image/metadata/ how to manually configure that.