Tuesday, March 01, 2005

Unexpected Signal 11 (Ocurre mucho con java)


OpenNMS will stop working after a period of time - this varies with the number of threads configured for the various daemons.

Intermittent servlet errors are encountered in the Web GUI - this seems to vary with the amount of concurrent usage of the GUI.

This has so far been reported with:

* Debian Woody/Sid, RedHat? 8.0/(7.x?), SuSe? 8.1
* OpenNMS 1.0.1
* Sun JDK 1.4.0, 1.4.1, 1.4.1_01
* Tomcat 4.0.3-0


Check for file like hs_err_pid9499.log in the directory that OpenNMS or Tomcat was launched.

It contains:

Unexpected Signal : 11 occurred at PC=0x404D4324
Function=size_given_klass__7oopDescP5Klass+0x44
Library=/usr/java/j2sdk1.4.1_01/jre/lib/i386/server/libjvm.so

Looking at the bottom of the dump file shows this:

#
# HotSpot? Virtual Machine Error : 11
# Error ID : 4F530E43505002E6
# Please report this error at
# http://java.sun.com/cgi-bin/bugreport.cgi
#
# Java VM: Java HotSpot(TM) Server VM (1.4.1_01-b01 mixed mode)

Doing a Google search on the error ID shows that it appears with other apps as well.

Here is an excerpt from one article:

I have seen this problem come up with a variety of applications, most notably JBoss 3.X. The way I got around it was specify the -Xrs and -Xint options to the VM before running any application.


Doing a "man java" gives:

-Xint Operates in interpreted-only mode. Compilation to
native code is disabled, and all bytecodes are exe-
cuted by the interpreter. The performance benefits
offered by the Java HotSpot VMs’ adaptive compiler
will not be present in this mode.


-Xrs Reduce usage of operating-system signals by Java
virtual machine (JVM).

Sun’s JVM catches signals to implement shutdown
hooks for abnormal JVM termination. The JVM uses
SIGHUP, SIGINT, and SIGTERM to initiate the running
of shutdown hooks. The JVM uses SIGQUIT to perform
thread dumps.

Applications that embed the JVM frequently need to
trap signals like SIGINT or SIGTERM, and in such
cases there is the possibility of interference
between the applications’ signal handlers and the
JVM shutdown-hooks facility.

To avoid such interference, the -Xrs option can be
used to turn off the JVM shutdown-hooks feature.
When -Xrs is used, the signal masks for SIGINT,
SIGTERM, SIGHUP, and SIGQUIT are not changed by the
JVM, and signal handlers for these signals are not
installed.


Note that -X options are non-standard and may change in the future.

Running with "-Xint -Xrs" results in stable operation.

In /opt/OpenNMS/bin/opennms.sh, find "HOTSPOT" and add the "X" flags like this:

if [ -n "$HOTSPOT" -a "$HOTSPOT" = true ] ; then
JAVA_CMD="$JAVA_CMD -server -Xint -Xrs"
fi


Also in /etc/tomcat4/conf/tomcat4.conf change the CATALINA_OPTS line like:

export CATALINA_OPTS="-Xint -Xrs -DTOMCATLAUNCH=true...

thats it...