Fwd: AOTCache + ZGC crashes

Suresh G sureshg.g at gmail.com
Sat Mar 22 04:51:56 UTC 2025


Hello Leyden Team,

I'm currently testing the new AOT cache feature with the latest OpenJDK 25
EA builds. My setup is straightforward, aiming to create a Docker image
with the AOT cache, much like I did previously with AppCDS.

Here is the docker multi-stage build for my sample Hello world app

  - Using openjdk:25-slim (25-ea+15-1670)
  - Compiling and creating app.jar
  - Getting module deps
    jdeps -q \
       -R \
       --ignore-missing-deps \
       --print-module-deps \
       --multi-release=25 \
       *.jar > ${APP_DIR}/java.modules

  - Creating jlinked image
    $JAVA_HOME/bin/jlink \
          --verbose \
          --module-path ${JAVA_HOME}/jmods \
          --add-modules="$(cat ${APP_DIR}/java.modules)" \
          --compress=zip-9 \
          --strip-debug \
          --strip-java-debug-attributes \
          --no-man-pages \
          --no-header-files \
          --save-opts "${APP_DIR}/jlink.opts" \
          --output ${RUNTIME_IMAGE}

  - Creating AOT cache
    echo "AOT training run for the app..."
    nohup ${RUNTIME_IMAGE}/bin/java \
        --show-version \
        --enable-preview \
        -XX:+UnlockExperimentalVMOptions \
        -XX:+UseCompactObjectHeaders \
        -XX:AOTMode=record -XX:AOTConfiguration=${APP_DIR}/app.aotconf \
        -jar ${APP_JAR} & \

    sleep 1 && \
    curl -fsSL --retry 5 --retry-delay 2 --retry-all-errors
http://localhost/test
    curl -fsSL http://localhost/shutdown || echo "AOT training run
completed!"

    echo "Creating AOT archive..."
    ${RUNTIME_IMAGE}/bin/java \
          --show-version \
          --enable-preview \
          -XX:+UnlockExperimentalVMOptions \
          -XX:+UseCompactObjectHeaders \
          -XX:AOTMode=create -XX:AOTConfiguration=${APP_DIR}/app.aotconf
-XX:AOTCache=${APP_DIR}/app.aot \
          -jar ${APP_JAR}

 - Now copy the APP_DIR to a distroless container (Final image)
 ---------------------------------------------------------------
---------------------

 I'm experiencing the following issues with the current build.

 1. JVM crashes with ZGC enabled:
    #
    # A fatal error has been detected by the Java Runtime Environment:
    #
    #  SIGSEGV (0xb) at pc=0x0000000105b4f318, pid=13825, tid=8963
    #
    # JRE version:  (25.0+15) (build )
    # Java VM: OpenJDK 64-Bit Server VM (25-ea+15-1670, interpreted mode,
sharing, compressed class ptrs, z gc, bsd-aarch64)
    # Problematic frame:
    # V  [libjvm.dylib+0x47f318]
 MetaspaceObjToOopHandleTable::set_oop(MetaspaceObj*, oopDesc*)+0x78
    #
    # No core dump will be written. Core dumps have been disabled. To
enable core dumping, try "ulimit -c unlimited" before starting    Java again
    #
    #

    ---------------  S U M M A R Y ------------

    Command Line: --enable-preview -XX:+UnlockExperimentalVMOptions
-XX:+UseCompactObjectHeaders -XX:+UseZGC -XX:AOTMode=create -XX:
 AOTConfiguration=app.aotconf -XX:AOTCache=app.aot app.jar

    Host: "MacBookPro18,1" arm64, 10 cores, 32G, Darwin 23.6.0, macOS
14.6.1 (23G93)
    Time: Fri Mar 21 20:21:47 2025 PDT elapsed time: 0.044457 seconds (0d
0h 0m 0s)

    ---------------  T H R E A D  ---------------

    Current thread (0x0000000136808c00):  JavaThread "Unknown thread"
[_thread_in_vm, id=8963, stack(0x000000016bd84000,    0x000000016bf87000)
(2060K)]

    Stack: [0x000000016bd84000,0x000000016bf87000],  sp=0x000000016bf86380,
 free space=2056k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code)
    V  [libjvm.dylib+0x47f318]
 MetaspaceObjToOopHandleTable::set_oop(MetaspaceObj*, oopDesc*)+0x78
    V  [libjvm.dylib+0x2d1b38]
 ConstantPool::restore_unshareable_info(JavaThread*)+0x20c
    V  [libjvm.dylib+0xa52928]  vmClasses::resolve_all(JavaThread*)+0xe0
    V  [libjvm.dylib+0x9a85cc]
 SystemDictionary::initialize(JavaThread*)+0xa0
    V  [libjvm.dylib+0xa0c8d0]  Universe::genesis(JavaThread*)+0x74
    V  [libjvm.dylib+0xa0f570]  universe2_init()+0x24
    V  [libjvm.dylib+0x497dac]  init_globals2()+0xc

2. AOT Cache generation fails during Docker cross-compilation:
Specifically, running docker build with --platform=linux/amd64 on ARM64
runner.

   36.70 + /opt/java/openjdk/bin/java --enable-preview
-XX:+UnlockExperimentalVMOptions -XX:+UseCompactObjectHeaders
-XX:AOTMode=create -XX:AOTConfiguration=/app/app.aotconf
-XX:AOTCache=/app/app.aot -jar app.jar
   36.70 Creating AOT archive...
   36.77 Error occurred during initialization of VM
   36.77 Must be a valid AOT configuration generated by the current JVM:
/app/app.aotconf


3. Also, are there plans to make the app.aotconf file cross-platform
compatible? This would allow us to generate the configuration once, and
then produce platform-specific caches from that configuration in CI systems
like GitHub Actions.


Thanks
Suresh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/leyden-dev/attachments/20250321/2168076d/attachment.htm>


More information about the leyden-dev mailing list