SIGSEGV in MethodCallBaton::resultsToV8
We are getting sporadic segfaults from node-java.
Here is the relevant part of the stack trace:
#0 0x00007f9068e215e5 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007f9068e22dc5 in abort () at abort.c:92
#2 0x00007f9056f73c65 in os::abort (dump_core=true) at /usr/src/debug/java-1.8.0-openjdk-1.8.0.131-0.b11.el6_9.x86_64/openjdk/hotspot/src/os/linux/vm/os_linux.cpp:1513
#3 0x00007f9057104e63 in VMError::report_and_die (this=0x7ffdf1146a60) at /usr/src/debug/java-1.8.0-openjdk-1.8.0.131-0.b11.el6_9.x86_64/openjdk/hotspot/src/share/vm/utilities/vmError.cpp:1060
#4 0x00007f9056f79932 in JVM_handle_linux_signal (sig=11, info=0x7ffdf1146c70, ucVoid=0x7ffdf1146b40, abort_if_unrecognized=-250320416) at /usr/src/debug/java-1.8.0-openjdk-1.8.0.131-0.b11.el6_9.x86_64/openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp:541
#5 0x00007f9056f6f623 in signalHandler (sig=11, info=0x7ffdf1146c70, uc=0x7ffdf1146b40) at /usr/src/debug/java-1.8.0-openjdk-1.8.0.131-0.b11.el6_9.x86_64/openjdk/hotspot/src/os/linux/vm/os_linux.cpp:4354
#6 <signal handler called>
#7 jni_IsInstanceOf (env=0x350e9e0, obj=0xa595a10, clazz=0x0) at /usr/src/debug/java-1.8.0-openjdk-1.8.0.131-0.b11.el6_9.x86_64/openjdk/hotspot/src/share/vm/prims/jni.cpp:1552
#8 0x00007f90643c3421 in MethodCallBaton::resultsToV8(JNIEnv_*) () from /opt/ericsson/itk/lib/node_modules/java/build/Release/nodejavabridge_bindings.node
#9 0x00007f90643bcf53 in JavaObject::methodCallSync(Nan::FunctionCallbackInfo<v8::Value> const&) () from /opt/ericsson/itk/lib/node_modules/java/build/Release/nodejavabridge_bindings.node
Note the null pointer passed in as clazz to jni_IsInstanceOf - I am pretty certain a null pointer is not allowed there.
The calling code in MethodCallBaton::resultsToV8 looks like this:
jclass invocationExceptionClazz = env->FindClass("java/lang/reflect/InvocationTargetException");
if (env->IsInstanceOf(m_error, invocationExceptionClazz)) {
...
so, it appears that FindClass must have returned null, which is not checked in the code. I am not sure how/why it cannot find this class.
Reading a little further, it seems that if NULL is returned from FindClass, you should check for an exception by calling env->ExceptionOccurred(). There are a number of exceptions which can be called. I suspect in my case it is throwing OutOfMemoryError as I am seeing other memory related crashes.