javadockermacos

I can't run the docker image on the m4-based macbook pro processor, which is build for jdk21


I tried to build a docker image, i write a Dockerfile to build it, the content below:


FROM  debian:latest

ENV DEBIAN_FRONTEND=noninteractive

WORKDIR /jdk

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y wget ca-certificates

RUN wget -O jdk-21_linux_bin.tar.gz https://download.oracle.com/java/21/latest/jdk-21_linux-aarch64_bin.tar.gz && \
    tar -xzf jdk-21_linux_bin.tar.gz && \
    folder_name=$(find . -maxdepth 1 -type d -name "*" ! -name "." | head -n 1) && \
    mv $folder_name jdk21 && \
    rm -f jdk-21_linux_bin.tar.gz

ENV JAVA_HOME=/jdk/jdk21
ENV PATH="${JAVA_HOME}/bin:${PATH}"

CMD ["java","-version"]

the build command is :

docker build -t debian-jdk21 .

But i got the error during building :

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x0000ffff97f3fc5c, pid=15, tid=16
#
# JRE version:  (21.0.6+8) (build )
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0.6+8-LTS-188, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-aarch64)
# Problematic frame:
# j  java.lang.System.registerNatives()V+0 java.base@21.0.6
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /jdk/hs_err_pid15.log
[0.025s][warning][os] Loading hsdis library failed
#
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted

i don't know how to fix it,

the follow is hs_err_pid15.log(Due to word limit, only part of it can be intercepted)

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

Command Line: 

Host: AArch64, 12 cores, 7G, Debian GNU/Linux 12 (bookworm)
Time: Sun Feb 23 13:58:48 2025 UTC elapsed time: 0.020505 seconds (0d 0h 0m 0s)

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

Current thread (0x0000ffffa8027620):  JavaThread "Unknown thread" [_thread_in_native, id=16, stack(0x0000ffffacd62000,0x0000ffffacf60000) (2040K)]

Stack: [0x0000ffffacd62000,0x0000ffffacf60000],  sp=0x0000ffffacf5e060,  free space=2032k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
j  java.lang.System.registerNatives()V+0 java.base@21.0.6
j  java.lang.System.<clinit>()V+0 java.base@21.0.6
v  ~StubRoutines::call_stub 0x0000ffff97f37158
V  [libjvm.so+0x800db8]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x218
V  [libjvm.so+0x7dceb0]  InstanceKlass::call_class_initializer(JavaThread*)+0x27c
V  [libjvm.so+0x7ddb54]  InstanceKlass::initialize_impl(JavaThread*)+0x404
V  [libjvm.so+0xd104f8]  Threads::initialize_java_lang_classes(JavaThread*, JavaThread*)+0xe8
V  [libjvm.so+0xd1264c]  Threads::create_vm(JavaVMInitArgs*, bool*)+0x3ec
V  [libjvm.so+0x88fe1c]  JNI_CreateJavaVM+0x7c
C  [libjli.so+0x438c]  JavaMain+0x7c
C  [libjli.so+0x79ec]  ThreadJavaMain+0xc
C  [libc.so.6+0x7ee90]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  java.lang.System.registerNatives()V+0 java.base@21.0.6
j  java.lang.System.<clinit>()V+0 java.base@21.0.6
v  ~StubRoutines::call_stub 0x0000ffff97f37158


VM Arguments:
java_command: <unknown>
java_class_path (initial): <not set>
Launcher Type: SUN_STANDARD

[Global flags]
     intx CICompilerCount                          = 4                                         {product} {ergonomic}
     uint ConcGCThreads                            = 3                                         {product} {ergonomic}
     uint G1ConcRefinementThreads                  = 10                                        {product} {ergonomic}
   size_t G1HeapRegionSize                         = 1048576                                   {product} {ergonomic}
    uintx GCDrainStackTargetSize                   = 64                                        {product} {ergonomic}
   size_t InitialHeapSize                          = 130023424                                 {product} {ergonomic}
   size_t MarkStackSize                            = 4194304                                   {product} {ergonomic}
   size_t MaxHeapSize                              = 2055208960                                {product} {ergonomic}
   size_t MaxNewSize                               = 1233125376                                {product} {ergonomic}
   size_t MinHeapDeltaBytes                        = 1048576                                   {product} {ergonomic}
   size_t MinHeapSize                              = 8388608                                   {product} {ergonomic}
    uintx NonNMethodCodeHeapSize                   = 5839564                                {pd product} {ergonomic}
    uintx NonProfiledCodeHeapSize                  = 122909338                              {pd product} {ergonomic}
    uintx ProfiledCodeHeapSize                     = 122909338                              {pd product} {ergonomic}
    uintx ReservedCodeCacheSize                    = 251658240                              {pd product} {ergonomic}
     bool SegmentedCodeCache                       = true                                      {product} {ergonomic}
   size_t SoftMaxHeapSize                          = 2055208960                             {manageable} {ergonomic}
     bool UseCompressedOops                        = true                           {product lp64_product} {ergonomic}
     bool UseG1GC                                  = true                                      {product} {ergonomic}

Logging:
Log output configuration:
 #0: stdout all=warning uptime,level,tags foldmultilines=false
 #1: stderr all=off uptime,level,tags foldmultilines=false

Environment Variables:
JAVA_HOME=/jdk/jdk21
PATH=/jdk/jdk21/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TERM=xterm

Active Locale:
LC_ALL=C
LC_COLLATE=C
LC_CTYPE=C
LC_MESSAGES=C
LC_MONETARY=C
LC_NUMERIC=C
LC_TIME=C

Signal Handlers:
   SIGSEGV: crash_handler in libjvm.so, mask=11100100010111111101111111111110, flags=SA_RESTART|SA_SIGINFO, unblocked
    SIGBUS: crash_handler in libjvm.so, mask=11100100010111111101111111111110, flags=SA_RESTART|SA_SIGINFO, unblocked
    SIGFPE: crash_handler in libjvm.so, mask=11100100010111111101111111111110, flags=SA_RESTART|SA_SIGINFO, unblocked
   SIGPIPE: javaSignalHandler in libjvm.so, mask=11100100010111111101111111111110, flags=SA_RESTART|SA_SIGINFO, blocked
   SIGXFSZ: javaSignalHandler in libjvm.so, mask=11100100010111111101111111111110, flags=SA_RESTART|SA_SIGINFO, blocked
    SIGILL: crash_handler in libjvm.so, mask=11100100010111111101111111111110, flags=SA_RESTART|SA_SIGINFO, unblocked
   SIGUSR2: SR_handler in libjvm.so, mask=00000000000000000000000000000000, flags=SA_RESTART|SA_SIGINFO, blocked
    SIGHUP: SIG_DFL, mask=00000000000000000000000000000000, flags=none, blocked
    SIGINT: SIG_DFL, mask=00000000000000000000000000000000, flags=none, blocked
   SIGTERM: SIG_DFL, mask=00000000000000000000000000000000, flags=none, blocked
   SIGQUIT: UserHandler in libjvm.so, mask=11100100010111111101111111111110, flags=SA_RESTART|SA_SIGINFO, blocked
   SIGTRAP: crash_handler in libjvm.so, mask=11100100010111111101111111111110, flags=SA_RESTART|SA_SIGINFO, unblocked


Periodic native trim disabled

---------------  S Y S T E M  ---------------

OS:
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
uname: Linux 6.12.5-linuxkit #1 SMP Tue Jan 21 10:23:32 UTC 2025 aarch64
OS uptime: 0 days 12:49 hours
libc: glibc 2.36 NPTL 2.36 
rlimit (soft/hard): STACK 8192k/infinity , CORE 0k/infinity , NPROC infinity/infinity , NOFILE 1048576/1048576 , AS infinity/infinity , CPU infinity/infinity , DATA infinity/infinity , FSIZE infinity/infinity , MEMLOCK infinity/infinity
load average: 1.79 2.09 1.98

/proc/meminfo:
MemTotal:        8024700 kB
MemFree:          137476 kB
MemAvailable:    6283572 kB
Buffers:          732112 kB
Cached:          5133836 kB
SwapCached:            0 kB
Active:          2086932 kB
Inactive:        5060412 kB
Active(anon):    1253352 kB
Inactive(anon):    28748 kB
Active(file):     833580 kB
Inactive(file):  5031664 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       1048572 kB
SwapFree:        1048572 kB
Zswap:                 0 kB
Zswapped:              0 kB
Dirty:               244 kB
Writeback:             0 kB
AnonPages:       1162264 kB
Mapped:           215872 kB
Shmem:               696 kB
KReclaimable:     483820 kB
Slab:             571456 kB
SReclaimable:     483820 kB
SUnreclaim:        87636 kB
KernelStack:        6960 kB
PageTables:         5716 kB
SecPageTables:         0 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     5060920 kB
Committed_AS:    2766672 kB
VmallocTotal:   135288315904 kB
VmallocUsed:        5600 kB
VmallocChunk:          0 kB
Percpu:             4512 kB
AnonHugePages:    888832 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
FileHugePages:         0 kB
FilePmdMapped:         0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:               0 kB

/sys/kernel/mm/transparent_hugepage/enabled: [always] madvise never
/sys/kernel/mm/transparent_hugepage/defrag (defrag/compaction efforts parameter): always defer defer+madvise [madvise] never

Process Memory:
Virtual Size: 4185044K (peak: 4245924K)
Resident Set Size: 36088K (peak: 36088K) (anon: 20096K, file: 15992K, shmem: 0K)
Swapped out: 0K
C-Heap outstanding allocations: 27880K, retained: 1035K
glibc malloc tunables: (default)

/proc/sys/kernel/threads-max (system-wide limit on the number of threads): 62643
/proc/sys/vm/max_map_count (maximum number of memory map areas a process may have): 262144
/proc/sys/kernel/pid_max (system-wide limit on number of process identifiers): 99999

container information not found.
Steal ticks since vm start: 0
Steal ticks percentage since vm start:  0.000

CPU: total 12 (initial active 12) 0x61:0x0:0x000:0, fp, asimd, evtstrm, aes, pmull, sha1, sha256, crc32, lse, dcpop, sha3, sha512, paca, sve2
/proc/cpuinfo:
processor   : 0
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 1
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 2
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 3
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 4
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 5
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 6
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 7
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 8
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 9
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 10
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0

processor   : 11
BogoMIPS    : 48.00
Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 flagm2 frint svei8mm svebf16 bf16 afp
CPU implementer : 0x61
CPU architecture: 8
CPU variant : 0x0
CPU part    : 0x000
CPU revision    : 0


Online cpus: 0-11
Offline cpus: 

Memory: 4k page, physical 8024700k(6283572k free), swap 1048572k(1048572k free)
Page Sizes: 4k

vm_info: Java HotSpot(TM) 64-Bit Server VM (21.0.6+8-LTS-188) for linux-aarch64 JRE (21.0.6+8-LTS-188), built on 2024-12-03T10:50:54Z by "mach5one" with gcc 11.2.0

END.

My macos enviroment info : OS: macOS Sequoia 15.3.1 (24D70) CPU: Apple M4 Pro 12 cores GPU: Apple M4 Pro 16 cores

I tried someone else's jdk21 mirror image, and the same error was still reported


Solution

  • To quote from the Docker forum:

    Looks like it’s a java bug specific to M4/Docker/MacOs 15.2. Really appreciate you taking a look, for now the recommended workaround of using JAVA_OPTS=“-XX:UseSVE=0” seems to be working.