Crash Dump Analysis: HsErr Files, Core Dumps, SIGSEGV

Read HotSpot fatal error logs, handle JNI references safely, and check Linux core-dump configuration before analyzing with GDB.

published: reading time: 9 min read author: Geek Workbench updated: November 8, 2026
Quick Summary

Read HotSpot fatal error logs, handle JNI references safely, and check Linux core-dump configuration before analyzing with GDB.

Crash Dump Analysis: HsErr Files, Core Dumps, SIGSEGV

HotSpot writes a fatal error log, often called an hs_err_pid or HsErr file, when it handles a fatal VM error. The log can show the signal, the thread state, stack frames, loaded libraries, and process details. It is evidence for an investigation, not a guaranteed explanation of the root cause.

The excerpts below are synthetic illustrations pinned to OpenJDK 17.0.2+8 HotSpot on Linux x86_64. Fatal-log fields and JVM options can vary by vendor and release. For a real crash, start with documentation and binaries that match the exact JDK build and operating environment.

Read the fatal error log

This shortened example shows the sort of information to look for:

# Synthetic excerpt for illustration only
# OpenJDK 17.0.2+8 HotSpot, Linux x86_64
# SIGSEGV (0xb) at pc=0x00007f0000001234, pid=2468, tid=2471
# Problematic frame:
# C  [libnative.so+0x1234]  Java_example_Native_decode+0x24
#
---------------  T H R E A D  ---------------
Current thread (0x00007f0000100000): JavaThread "worker-1"
Native frames: (J=compiled Java, j=interpreted Java, C=native)
C  [libnative.so+0x1234]  Java_example_Native_decode+0x24
j  example.Native.decode([B)V+0

The Problematic frame identifies the frame associated with the reported program counter. It does not prove that this function introduced the bug. The native frame may be where earlier memory corruption became visible. Optimized or inlined Java code can also make the stack incomplete or hard to map back to source. Compare the HsErr frames with application logs, the exact native libraries, and a matching core dump when one is available.

For a first pass, search for the signal, reported frame, current thread, and native frames:

grep -n -E 'SIG[A-Z]+|Problematic frame|Current thread|Native frames|Dynamic libraries' hs_err_pid*.log
HsErr section Useful evidence
Header Signal, program counter, process and thread IDs, JDK build
Problematic frame Reported frame and library offset near the fault
Current thread Registers and frames for the thread that encountered the error
Process and system details Other threads, loaded libraries, OS and CPU information

HotSpot 17 supports -XX:ErrorFile=/var/log/myapp/hs_err_%p.log, where %p is replaced by the process ID. The directory must exist and be writable by the JVM process. Without that option, the JDK 17 documentation says HotSpot first tries the process working directory and then the operating system’s temporary directory on Linux, usually /tmp. Confirm the behavior for the vendor and release you run, and check stderr for the reported file location. See Oracle’s JDK 17 fatal error log guide.

Interpret the signal with care

  • SIGSEGV means the process encountered an invalid memory access. JNI code or another native library may be involved, but the signal alone does not identify the cause.
  • SIGABRT often follows an explicit abort or fatal VM check. Read the fatal-error description and surrounding log before deciding whether it came from the application, a library, or the VM.
  • SIGFPE is Linux’s arithmetic-error signal. Integer division by zero has undefined results in C and can generate SIGFPE on some architectures; signed overflow is not a reliable trigger. Java integer division by zero throws ArithmeticException, while floating-point division follows IEEE 754 rules. A SIGFPE in a JVM process still needs investigation rather than an assumption that JNI caused it. See the Linux signal(2) manual and the Java Language Specification’s division rules.

Keep JNI references and buffers distinct

A jstring or jobject passed into a native method is a JNI reference. A local reference is valid for the native call’s lifetime and on its current thread; do not retain it after the call returns or use it from another thread. If native code needs an object later, create a global reference with NewGlobalRef, then release it with DeleteGlobalRef when finished.

GetStringUTFChars returns a modified UTF-8 character buffer, not a Java object reference. Pair a successful call with ReleaseStringUTFChars for the same string, and do not use the buffer after release. For example:

JNIEXPORT void JNICALL
Java_example_Native_log(JNIEnv *env, jobject self, jstring input) {
    (void) self;
    const char *text = (*env)->GetStringUTFChars(env, input, NULL);
    if (text == NULL) {
        return;  // A JNI exception may be pending.
    }

    consume_text(text);  // Application-specific; must not keep the pointer.
    (*env)->ReleaseStringUTFChars(env, input, text);
}

The example omits application-specific error handling. Make sure every path after acquiring the buffer releases it. The JNI design guide explains local and global reference lifetimes; the JNI function reference documents string access and release functions.

Which artifact helps?

Artifact Use it to Limits
HsErr file Read the reported signal, thread context, and loaded-library details. It may be incomplete and does not preserve the full process memory.
Core dump Inspect process state in a debugger when the text log leaves questions. Capture may be disabled, redirected, truncated, or omit memory regions; the file is sensitive.
Application logs Correlate the crash time with requests, deployments, and application-level events. Logs cannot show arbitrary memory or native state from the stopped process.

Check Linux core-dump capture

A core dump can help inspect thread stacks and memory after a crash, but Linux does not guarantee that a file will be created. Capture depends on the process RLIMIT_CORE and RLIMIT_FSIZE limits, the signal, permissions, writable storage and available space, kernel.core_pattern, and whether the kernel has core-dump support enabled. A dump can also omit or truncate memory regions.

Start by inspecting the process environment and host configuration:

# Run in the same shell or service context that starts the JVM.
ulimit -c
ulimit -f
cat /proc/sys/kernel/core_pattern

For a systemd service, check its LimitCORE setting and the host’s systemd-coredump configuration. coredumpctl can list, inspect, and export dumps that systemd retained; it will not recover a dump that was never captured or has already been removed. In a container, check the runtime’s resource limits, writable mounts, node-level core handler, and retention policy. These settings often require changes outside the container.

gcore <PID> asks GDB to capture a running process; it is not a way to retrieve a core after the process has exited. Attaching may be blocked by ptrace permissions or container policy. Do not add CAP_SYS_PTRACE or change host-wide core settings without following the environment’s operational controls.

Open a core with matching files

Use the executable, libjvm, native libraries, and debug information that match the crashed process. A core from another JDK build or architecture can produce misleading frames. Separate debug-symbol packages and file locations vary by distribution; an address that remains unresolved is not proof that the frame is empty or irrelevant.

gdb /path/to/matching-jdk/bin/java /path/to/core.dump

At the GDB prompt, inspect threads and registers:

(gdb) thread apply all bt
(gdb) info registers

If the matching shared libraries are outside GDB’s search path, configure the path to those exact files before drawing conclusions from unresolved frames. Keep the executable, libraries, debug symbols, and core together as one analysis set. The GDB manual documents core-file and shared-library handling.

Illustrative failure patterns

These examples are hypothetical patterns, not reports of real incidents.

  • JNI string-buffer misuse: A native method releases a buffer returned by GetStringUTFChars and later passes the stale pointer to another C function. The HsErr may show a native frame near the fault. Review buffer ownership and release paths; the frame alone does not prove this scenario occurred.
  • Native memory corruption: A library writes beyond an allocated buffer, while a later operation faults in a different function. Compare native frames and, when possible, inspect a core with matching symbols. The visible fault location may be downstream from the original write.
  • No core file appears: An HsErr exists, but no core is available. Check the service’s resource limits, core_pattern, systemd handling, container runtime, permissions, and storage before changing the JVM flags.

Before an incident

  • Configure a writable -XX:ErrorFile location for the exact HotSpot build, then confirm where the file is written in that environment.
  • Record the JDK vendor, full build string, JVM flags, OS and architecture, container image, and native library versions with the incident.
  • Decide whether the service should retain core dumps. Check limits, storage capacity, access controls, and cleanup policy with the system owner.
  • Keep matching native binaries and debug symbols available for the build that is deployed.
  • Correlate the crash timestamp with application logs and deployment metadata; avoid treating correlation as proof of cause.

Handle crash files as sensitive data

An HsErr file may include command-line arguments, environment values, paths, thread names, and library details. A core dump can contain process memory, including user data, credentials, or cryptographic material. Store both with restricted access and encryption, define a retention period, and review them before sharing outside the team.

Quick recap

  • Read the signal, problematic frame, current-thread stack, and JDK build as evidence, not a root-cause verdict.
  • Keep JNI object references separate from buffers returned by string and array access functions.
  • Check Linux and systemd limits, kernel configuration, container behavior, permissions, and storage before expecting a core file.
  • Use the exact executable, libraries, architecture, and debug symbols that match the crashed process.
  • Restrict crash artifacts because they can contain sensitive process data.

Interview questions

1. Does the HsErr problematic frame identify the root cause?
No. It identifies the frame associated with the reported program counter. Memory corruption, optimized code, or missing symbols can make the original cause hard to locate.
2. What is the difference between a JNI reference and a string buffer?
A JNI reference identifies a Java object and has local or global lifetime rules. A pointer returned by GetStringUTFChars is a character buffer that must be paired with ReleaseStringUTFChars; it is not the object reference.
3. Why might Linux not create a core file?
The process limits, signal, permissions, filesystem, kernel configuration, core_pattern, systemd handler, or container runtime can prevent or redirect capture. Inspect the service and host configuration together.
4. Why are matching binaries and symbols important in GDB?
GDB uses the executable and shared libraries to interpret addresses from the core. Files from a different build or architecture can leave frames unresolved or produce misleading output.

Further reading

Category

Related Posts

JVMTI Agents: Native Access to the JVM

Learn how JVMTI agents register events, request capabilities, and collect JVM data while managing callback cost, native memory, and compatibility.

#jvm #jvmti #profiling

Deoptimization Debugging: When JIT Compiled Code Reverts

Learn what causes the JVM to deoptimize JIT-compiled code, how to detect deoptimization events, and how to fix the underlying issues.

#jvm #jit #deoptimization

Java Flight Recorder: Continuous Monitoring and Diagnostics

Learn Java Flight Recorder setup, storage limits, overhead measurement, and practical analysis with Oracle JDK 25 and JMC 9.1.2.

#jvm #java #profiling