我在Apache Spark Cluster(使用Linux运行的节点(Oracle 6.7))上使用JNA 4.2.1与本机库进行交互。很少,我的JVM因本机库发送的SIGSEGV信号而崩溃,这使我的整个spark应用程序失败。
因此我希望保护我的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
,因为我无法设置相应的环境变量(我无法访问系统,因为它是群集节点)。
我做错了什么?
答案 0 :(得分:0)
没有from pymodbus.client.sync import ModbusTcpClient as ModbusClient
client = ModbusClient( host='192.168.0.1', port=502)
try:
while True:
temp1 = ReadSensor( 'sensor1' ) #function returns a temperature, works ok
temp2 = ReadSensor( 'sensor2' )
setpoint = ?? #how do I fetch a given input field
#from html here?
#read holding registers 0 to 4
rr = client.read_holding_registers(0x00,4,unit=0x00)
print rr.registers #This values should appear on html
#send write command to modbus server
address = 11
client.write_registers(address, [temp1, temp2, setpoint])
except KeyboardInterrupt:
pass
client.close()
,linux上的保护模式不起作用。无论如何,这不是你应该依赖的东西,因为它在线程环境中不可靠。