在JNA中使用受保护模式后,甚至会发生更多JVM崩溃

问题描述:

我正在Apache Spark群集(使用Linux(Oracle 6.7)运行的节点)上使用JNA 4.2.1与本地库进行接口连接。很少,我的JVM由于本机库发送的SIGSEGV信号而崩溃,这使得我的整个spark应用程序失败。在JNA中使用受保护模式后,甚至会发生更多JVM崩溃

所以我要保护我的JVM,因为这崩溃,所以我看着JNA的保护模式,应转化本地信号转换成JVM异常:

于是我就用

System.setProperty("jna.protected","true") 
Native.setProtected(true) 

前我加载与

Native.loadLibrary(... 

图书馆这样做后,我得到更多的SIGSEGV S,这里的一些例子:

# 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 

请注意,我没有指定libjsig.so,因为我无法设置相应的环境变量(由于它是群集节点,我无法访问系统)。

我在做什么错了?

没有libjsig.so,linux上的受保护模式不起作用。无论如何,这不是您应该依赖的东西,因为它在线程环境中不可靠。

+0

有没有一种方法可以在调用库的代码中以编程方式设置'LD_PRELOAD',还是需要在JVM启动之前设置它? –

+0

好的我已经想通了......对于那些也在使用Spark的人:可以使用spark选项'spark.executorEnv.LD_PRELOAD'来设置executors环境变量 –