The Java HotSpot VM installs signal handlers to implement various features and to handle fatal error conditions. For example, in an optimization to avoid explicit null checks in cases where java.lang.NullPointerException
will be thrown rarely, the SIGSEGV
signal is caught and handled, and the NullPointerException
is thrown.
In general there are two categories of situations where signal/traps arise:
When signals are expected and handled, like the implicit null-handling cited above. Another example is the safepoint polling mechanism, which protects a page in memory when a safepoint is required. Any thread that accesses that page causes a SIGSEGV
, which results in the execution of a stub that brings the thread to a safepoint.
Unexpected signals. This includes a SIGSEGV
when executing in VM code, Java Native Interface (JNI) code, or native code. In these cases the signal is unexpected, so fatal error handling is invoked to create the error log and terminate the process.
Table 7-2 lists the signals that are currently used on Oracle Solaris and Linux operating systems.