Video in progress
The JVM crashed and left an hs_err_pid file. How do you read it, and what are your next steps?
First I look at the crash cause (SIGSEGV, SIGBUS, native OOM) and the frame and thread that crashed. Depending on whether the frame is in the JVM itself, in JIT code or in a native library, I pick the path: updating the JDK, excluding the method from compilation, or replacing the library.
📖 Answer
Crashes in Java are rare, so when one happens it is serious. The most important parts of hs_err_pid<pid>.log:
# SIGSEGV (0xb) at pc=0x00007f..., pid=1, tid=57
# JRE version: OpenJDK Runtime Environment (21.0.2+13)
# Problematic frame:
# J 4211 c2 com.acme.Codec.decode([BI)I (312 bytes) @ 0x...
The frame type says a lot:
J: JIT-compiled Java code. Often a JIT bug. A temporary workaround: exclude that method from compilation (-XX:CompileCommand=exclude,com.acme.Codec::decode) and try a newer patch version of the JDK.V: inside the JVM (for example, the GC). Search the JDK bug tracker with that stack; updating often fixes it.C: a native library (JNI). For example a compression, crypto or image library. This is often the culprit.SIGBUSand mapped files: the file may have been truncated or the disk may be full.
The other sections in the file: the thread that crashed and its stack, the list of all threads, the heap state, flags and /proc/meminfo. If it says "Native memory allocation (mmap) failed", that isn't a crash but running out of memory: look at the container limit and swap.
In a container this matters: write the file to a persistent volume with -XX:ErrorFile=/logs/hs_err_%p.log, otherwise it is lost when the pod is recreated. If you need a core dump, have ulimit -c and the container settings ready in advance. If the crash repeats, reducing it to a minimal case and sending it to the distribution vendor or to OpenJDK as a bug is also a staff-level job.
Sign up to mark studied questions and save your progress.