The VM supports diagnostic flags -XX:+SafepointTimeout and -XX:+AbortVMOnSafepointTimeout to detect safepoint synchronization timeouts and to exit with an error message.
However, we usually don't see what the thread was doing which didn't reach the safepoint.
We can get a more helpful hs_err file if we kill that thread and let it dump the hs_err file.
Note: This feature doesn't work on Windows. Some additional information (si_code, "sent by kill") is only displayed on linux.
New hs_err output:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGILL (0x4) at pc=... (sent by kill), ...
#
The "T H R E A D" section should show a stack trace showing what the thread was actually doing.
The "printing siginfo" step should show more info like si_code (SI_TKILL), pid of the sender, etc if possible.
An Event is added:
Event: ... Thread ... sent signal 4 to Thread ... because blocking a safepoint.
Flags for using the feature this way:
-XX:+UnlockDiagnosticVMOptions
-XX:+SafepointTimeout
-XX:+SafepointALot
-XX:+AbortVMOnSafepointTimeout
-XX:SafepointTimeoutDelay=500
-XX:GuaranteedSafepointInterval=500