Skip to content
Latchkey

Maven Surefire "The forked VM terminated without saying goodbye"

Surefire’s forked test JVM died unexpectedly - it crashed, was OOM-killed by the kernel, or called System.exit. Surefire lost contact with it and reports it "terminated without properly saying goodbye".

What this error means

The test phase fails with The forked VM terminated without properly saying goodbye. VM crash or System.exit called? and the exact command line Surefire used to launch the fork. There is no normal test report.

mvn output
[ERROR] Failed to execute goal ...:test ...
The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Command was /bin/sh -c cd ... && /opt/jdk/bin/java -jar surefire/surefirebooter.jar ...

Common causes

Forked test JVM OOM-killed

The forked JVM (plus the Maven JVM and any others) exceeded the runner memory and the kernel SIGKILLed it. Surefire sees the fork vanish.

A native crash or System.exit in a test

A JNI/native library segfault, or a test that calls System.exit, terminates the fork abruptly so it never reports back.

How to fix it

Cap forked heap and reduce parallelism

Size the forked JVM heap to fit alongside the other JVMs, and lower fork count.

Terminal
mvn -B test \
  -DargLine="-Xmx1g" \
  -DforkCount=1 -DreuseForks=true

Find native crashes or stray System.exit

  1. Check for a hs_err_pid*.log next to the working dir - it pinpoints a native/JVM crash.
  2. Grep tests for System.exit( - a test must never call it.
  3. Lower forkCount so concurrent JVMs do not oversubscribe memory.

How to prevent it

  • Size -DargLine="-Xmx..." and forkCount to the runner RAM.
  • Forbid System.exit in test code.
  • Capture hs_err_pid*.log as a CI artifact for native crashes.

Frequently asked questions

What causes ""The forked VM terminated without ... goodbye""?
The forked JVM (plus the Maven JVM and any others) exceeded the runner memory and the kernel SIGKILLed it. Surefire sees the fork vanish.
How do I fix "The forked VM terminated without ... goodbye"?
Size the forked JVM heap to fit alongside the other JVMs, and lower fork count.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card