I'm interfacing with a native library using JNA 4.2.1 on a Apache Spark Cluster (nodes running with Linux (Oracle 6.7)). Very rarely, my JVM crashes because of a SIGSEGV Signal sent by the native library, which makes my entire spark-application fail.
So I want to protect my JVM to Crash because of this, so I looked into the protected mode of JNA which should translate native signals into JVM exception:
So I use
System.setProperty("jna.protected","true")
Native.setProtected(true)
before I load the library with
Native.loadLibrary(...
After doing this, I get even more SIGSEGV
s, here some examples:
# SIGSEGV (0xb) at pc=0x00007f203b4b7c13, pid=92730, tid=139775595345664
#
# JRE version: Java(TM) SE Runtime Environment (8.0_60-b27) (build 1.8.0_60-b27)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.60-b23 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x440c13] ciBytecodeStream::get_method(bool&, ciSignature**)+0x513
#
# SIGSEGV (0xb) at pc=0x00007f29ef518f5c, pid=73559, tid=139817217382144
#
# JRE version: Java(TM) SE Runtime Environment (8.0_60-b27) (build 1.8.0_60-b27)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.60-b23 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x6e0f5c] jni_GetArrayLength+0x6c
# SIGSEGV (0xb) at pc=0x00007f27b5c01a8c, pid=73454, tid=139807714744064
#
# JRE version: Java(TM) SE Runtime Environment (8.0_60-b27) (build 1.8.0_60-b27)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.60-b23 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x413a8c] ciEnv::get_field_by_index(ciInstanceKlass*, int)+0x22c
# SIGSEGV (0xb) at pc=0x00007f46f913aba5, pid=133097, tid=139942002874112
#
# JRE version: Java(TM) SE Runtime Environment (8.0_60-b27) (build 1.8.0_60-b27)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.60-b23 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x432ba5] ciObjArrayKlass::make(ciKlass*)+0x85
Note that I don't specify libjsig.so
as I can't set the corresponding enviromental variable (I have no access to the System as it is a cluster node).
What I'm doing wrong?
Protected mode on linux doesn't work without libjsig.so
. It's not something you should rely on in production anyway, since it's not reliable in a threaded environment.