Java process crashed with the message "Native memory allocation (mprotect) failed to protect 16384 bytes for memory to guard stack pages".
Issue
My java process crashed with the message "Native memory allocation (mprotect) failed to protect 16384 bytes for memory to guard stack pages" in fatal error log like (*1-1) below.
(*1) Excerpt from fatal error log (hs_err_pid<pid>.log
)
#
# A fatal error has been detected by the Java Runtime Environment:
# Native memory allocation (mprotect) failed to protect 16384 bytes for memory to guard stack pages <---------- (*1-1)
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Zero Based Compressed Oops mode in which the Java heap is
# placed in the first 32GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 32GB virtual address.
# This output file may be truncated or incomplete.
#
# Internal Error (thread.cpp:2636), pid=76142, tid=108791
# Error: memory to guard stack pages
#
Also, the stack trace in the fatal error log indicates that the java process crashed when it tried to create stack guard pages like (*2-1) in OpenJDK 11 or (*3-1) in OpenJDK 17.
(*2) Stack trace at crash time in OpenJDK 11
Stack: [0x00007f1a34f10000,0x00007f1a35011000], sp=0x00007f1a3500fa10, free space=1022k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0xee1aaa] VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x1ca
V [libjvm.so+0xee2a2f] VMError::report_and_die(Thread*, char const*, int, unsigned long, VMErrorType, char const*, __va_list_tag*)+0x2f
V [libjvm.so+0x6ba27d] report_vm_out_of_memory(char const*, int, unsigned long, VMErrorType, char const*, ...)+0xdd
V [libjvm.so+0xe7caed] JavaThread::create_stack_guard_pages()+0xed <---------- (*2-1)
V [libjvm.so+0xe7e4a0] JavaThread::run()+0x30
V [libjvm.so+0xe7a26c] Thread::call_run()+0x15c
V [libjvm.so+0xc2e03e] thread_native_entry(Thread*)+0xee
(*3) Stack trace at crash time in OpenJDK 17
Stack: [0x00007f3a84552000,0x00007f3a84653000], sp=0x00007f3a84651a40, free space=1022k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0xf7cf56] VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x1a6
V [libjvm.so+0xf7dc5f] VMError::report_and_die(Thread*, char const*, int, unsigned long, VMErrorType, char const*, __va_list_tag*)+0x2f
V [libjvm.so+0x622e05] report_vm_out_of_memory(char const*, int, unsigned long, VMErrorType, char const*, ...)+0xf5
V [libjvm.so+0xe2d225] StackOverflow::create_stack_guard_pages()+0xe5 <---------- (*3-1)
V [libjvm.so+0xefe594] JavaThread::run()+0x44
V [libjvm.so+0xf017f1] Thread::call_run()+0x71
V [libjvm.so+0xc33459] thread_native_entry(Thread*)+0xe9
Environment
- OpenJDK
- 11
- 17
- Red Hat Enterprise Linux
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.