skip to content

A JVM in production died three times this week with exit codes 134, 137 and 3. How do you tell a HotSpot crash from a kernel OOM kill or an ExitOnOutOfMemoryError exit?

level: seniorimportance: should knowfreq 36%

answer

  1. 128 plus the signal number
  2. SIGABRT versus SIGKILL
  3. status 3 is a deliberate exit
  4. which evidence each one leaves
  5. absence of a file is evidence

basics

~20 s

134 is SIGABRT, HotSpot aborting after a crash, with an hs_err file; 137 is SIGKILL, typically the kernel OOM killer, leaving no file but a kernel log record; 3 is -XX:+ExitOnOutOfMemoryError exiting after a 'Terminating due to java.lang.OutOfMemoryError' line.

solid answer

~40 s

Shells and container runtimes report a signal death as 128 plus the signal number. **134** is `SIGABRT`: HotSpot's error handler aborts after a fatal error, so there should be an `hs_err_pid<pid>.log` and the stdout banner naming it. **137** is `SIGKILL`, which cannot be caught: no crash log, no shutdown hooks, and if it was the kernel's OOM killer, a `Killed process` record in the kernel log and, in Kubernetes, `OOMKilled` on the container status; a resident set growing past the heap points to native memory. **3** is not a signal at all: `-XX:+ExitOnOutOfMemoryError` prints `Terminating due to java.lang.OutOfMemoryError: <message>` and exits with status 3, so the Java heap or another JVM memory area really ran out. Each death leaves different evidence, and I check that the evidence matches the code before I trust it.

code

bash · 4 lines
bash
# what the process left behind
ls -l /crash/hs_err_pid*.log           # a file means HotSpot's error handler ran
grep -m1 'Terminating due to' app.log  # the -XX:+ExitOnOutOfMemoryError line
dmesg -T | grep -i 'killed process'    # the kernel's OOM kill record

go deeper

for a junior

Recall that 134 is SIGABRT, 137 is SIGKILL, and that a signal death is reported as 128 plus the signal number.

for a middle

Name the artefact each death leaves: an hs_err file, a kernel OOM record, or a Terminating due to java.lang.OutOfMemoryError line with status 3.

for a senior

Corroborate every exit code with its artefact, explain why a missing crash log matters, and route each death to the right next investigation.

for a principal

Decide which exit policy a fleet uses on OutOfMemoryError, and make sure exit codes, crash logs and kernel records land in one place for every death.

## Exit codes are a first sort, not a diagnosis On Linux, a process that ends normally has an **exit status** from 0 to 255. A process ended by a signal has no exit status; shells and container runtimes report it as **128 plus the signal number**. That convention turns three very different deaths into three numbers. | Code | Meaning | Who caused it | Evidence it leaves | |---|---|---|---| | 134 | killed by `SIGABRT` (6) | HotSpot's error handler, after a fatal error | `hs_err_pid<pid>.log`, the `#` banner on stdout, maybe a core dump | | 137 | killed by `SIGKILL` (9) | the kernel's OOM killer, or anything that sent `kill -9` | nothing from the JVM; a kernel log record if it was an OOM kill | | 3 | exit status 3 | the JVM itself, under `-XX:+ExitOnOutOfMemoryError` | a `Terminating due to java.lang.OutOfMemoryError: …` line | ## 134: the JVM crashed When HotSpot hits a fatal signal or an internal error, its handler writes the report and then calls `abort()`, which raises `SIGABRT`. With the default `-XX:+CreateCoredumpOnCrash` that is what normally ends a crash, so the original `SIGSEGV` shows up as 134. Confirm it: - look for the `hs_err_pid<pid>.log` file (working directory, the `-XX:ErrorFile` path, or the temp directory); - look in the console output for `# A fatal error has been detected by the Java Runtime Environment:` and the `# An error report file with more information is saved as:` line; - note whether the header says a core dump will be written. A 134 with no crash log anywhere is worth a second look: something else in the process, such as a native library calling `abort()` itself, can raise the same signal. Note too that if crash core dumps are turned off with `-XX:-CreateCoredumpOnCrash`, a crash may not end with `SIGABRT` at all, so it is the crash log, not the 134, that proves a HotSpot crash. ## 137: something killed the JVM from outside `SIGKILL` cannot be caught or handled, so the JVM writes nothing: no crash log, no shutdown hooks, no final log line. The application log simply stops. The evidence is outside the process: - the kernel log (`dmesg`, or the journal) records an OOM kill with the process name and its memory at the time; - in Kubernetes the container's last state shows `Reason: OOMKilled` when the cgroup limit was hit; - otherwise, look for who else could send `kill -9`: a deployment tool or a supervisor that gave up waiting. For a JVM, an OOM kill while the heap after GC looks healthy means the **resident set** (heap plus everything outside it: thread stacks, metaspace, the code cache, direct buffers, native libraries) outgrew the limit. That is a native-memory investigation, not a crash investigation, and not a heap one. ## 3: an orderly exit on OutOfMemoryError With `-XX:+ExitOnOutOfMemoryError`, the first `OutOfMemoryError` the JVM throws makes it print `Terminating due to java.lang.OutOfMemoryError: <message>` and exit at once with status 3, without running shutdown hooks. That is a policy the team chose so the orchestrator restarts a JVM that ran out of memory rather than limping on. The message after the colon names which area ran out, and a heap dump written by `-XX:+HeapDumpOnOutOfMemoryError` (if configured) is the evidence to read next. The related `-XX:+CrashOnOutOfMemoryError` instead prints `Aborting due to java.lang.OutOfMemoryError: …` and crashes on purpose, producing a crash log and, if allowed, a core dump, so it typically shows up as 134. ## Check the evidence against the number A triage note should say both the code and the corroborating evidence, because each one can mislead alone: 1. Read the exit code or signal from the orchestrator or the service manager. 2. Look for the artefact that death should leave: a crash log, a kernel record, a `Terminating due to` line. 3. If the artefact is missing, ask why (an ephemeral working directory, a log pipeline that dropped the last lines) before you accept the classification. 4. Only then open the matching investigation: the crash log's problematic frame, native memory growth, or the `OutOfMemoryError` message and heap dump. Three deaths with three codes in one week may also be one cause seen three ways, for example native code that leaks until the kernel kills the JVM and occasionally corrupts memory and crashes it first. Line them up by time against memory graphs and deploys before treating them as separate incidents.

  • Why does a JVM killed with exit code 137 leave no final line in its application log, even with a shutdown hook that logs?
    Because `SIGKILL` cannot be caught, so the kernel removes the process without running any of its code: no signal handler, no shutdown hooks, no flush of buffered log output. The only evidence is outside the process, in the kernel log or the orchestrator's record of the container's last state.
  • Why would a team choose -XX:+ExitOnOutOfMemoryError over letting the OutOfMemoryError propagate?
    After an `OutOfMemoryError`, threads may have died halfway through work and shared state may be inconsistent, so a JVM that keeps running can fail in confusing ways. Exiting at once with status 3 lets the orchestrator restart a clean process, and a heap dump captured just before it preserves the evidence.

  • Reads exit code 137 as a JVM crash and hunts for an hs_err file.
  • Expects shutdown hooks or a final log line after a SIGKILL.
  • Thinks exit status 3 means the JVM was killed by signal 3.
  • Assumes every 134 was raised by HotSpot without finding the crash log.
  • Treats an OOM kill with a flat heap as a Java heap problem.

Assumes JDK 25: ExitOnOutOfMemoryError prints 'Terminating due to java.lang.OutOfMemoryError' and exits with status 3, as in the jdk25u source.