Skip to content
Latchkey

Maven Surefire "The forked VM terminated without saying goodbye"

Surefire runs tests in a forked JVM. This error means that JVM died abruptly - no clean shutdown handshake. On CI it is almost always the OOM killer terminating the forked process, or a test that called System.exit.

What this error means

The test phase fails with The forked VM terminated without properly saying goodbye. VM crash or System.exit called?, often quoting the exact command Surefire used to launch the forked JVM. There is no assertion failure - the process vanished.

mvn output
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:3.2.5:test (default-test) on
project app: The forked VM terminated without properly saying goodbye.
VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /workspace && /opt/jdk/bin/java -jar ...surefirebooter.jar

Common causes

Forked test JVM OOM-killed

The forked JVM’s heap plus the Maven process exceeded the runner’s RAM, so the kernel SIGKILLed the test JVM. It dies before it can report back, producing this exact message.

A test (or native code) crashed or called System.exit

A test invoking System.exit, or a native library segfaulting (a hs_err_pid dump appears), terminates the forked JVM uncleanly.

How to fix it

Cap the forked test heap to fit the runner

Set Surefire’s forked JVM args so the test heap, plus Maven, fits in RAM.

pom.xml (surefire)
<configuration>
  <argLine>-Xmx1g -XX:MaxMetaspaceSize=256m</argLine>
  <forkCount>1</forkCount>
  <reuseForks>true</reuseForks>
</configuration>

Reduce parallelism or find the crash

  1. Lower forkCount so fewer test JVMs run at once on a small runner.
  2. Check for a hs_err_pid*.log (a JVM crash dump) or a native-library segfault.
  3. Grep tests for a stray System.exit call that kills the forked VM.

How to prevent it

  • Set Surefire <argLine> heap relative to the runner RAM.
  • Bound forkCount so concurrent test JVMs do not exhaust memory.
  • Never call System.exit in tests; assert and return instead.

Frequently asked questions

What causes ""forked VM terminated without properly saying goodbye""?
The forked JVM’s heap plus the Maven process exceeded the runner’s RAM, so the kernel SIGKILLed the test JVM. It dies before it can report back, producing this exact message.
How do I fix "forked VM terminated without properly saying goodbye"?
Set Surefire’s forked JVM args so the test heap, plus Maven, fits in RAM.
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