JNI申请挂起

时间:2017-09-11 23:23:01

标签: java c++ c hadoop java-native-interface

请帮助您如何调试JNI应用程序。

使用jps获取正在运行jvm的进程的pid:

$ jps
8248                <- this is the pid of the process that was span up by a C++ application to run JNI stuff ... 
8335 Jps

现在我们可以将gdb附加到此堆栈。

$ gdb -p 8248
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-94.el7
....  /cut/   
(gdb)
(gdb) bt
#0  0x00007fddd9f141bd in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x00007fddd9f0fd02 in _L_lock_791 () from /lib64/libpthread.so.0
#2  0x00007fddd9f0fc08 in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x00007fddda9f3e26 in mutexLock () from /opt/cloudera/parcels/CDH/lib64/libhdfs.so.0.0.0
#4  0x00007fddda9ed6f1 in setTLSExceptionStrings () from /opt/cloudera/parcels/CDH/lib64/libhdfs.so.0.0.0
#5  0x00007fddda9ec38c in printExceptionAndFreeV () from /opt/cloudera/parcels/CDH/lib64/libhdfs.so.0.0.0
#6  0x00007fddda9ec52d in printExceptionAndFree () from /opt/cloudera/parcels/CDH/lib64/libhdfs.so.0.0.0
#7  0x00007fddda9ed46b in getJNIEnv () from /opt/cloudera/parcels/CDH/lib64/libhdfs.so.0.0.0
#8  0x00007fddda9eee94 in hdfsBuilderConnect () from /opt/cloudera/parcels/CDH/lib64/libhdfs.so.0.0.0
#9  0x0000000000400950 in main ()

请注意,它悬挂在某种全局互斥锁中

我认为这个gdb回溯堆栈对于确定此问题的根本原因非常有用。

这应该是一个通用的JNI调试问题吗?如果您对此处感兴趣的是跨越JVM进行JNi交互的C代码 - https://gist.github.com/Tagar/7c42f82f5538004bda2f4ea0b0e0adc5

java版&#34; 1.8.0_141&#34; gcc版本4.8.5 20150623(Red Hat 4.8.5-11)(GCC)

运行时环境:

export LD_LIBRARY_PATH=$CDH/lib64:$JAVA_HOME/jre/lib/$OS_ARCH/server
export CLASSPATH=`hadoop classpath` 
export _JAVA_OPTIONS=-Xss1280m

感谢任何线索。

此外,基于悬挂堆栈,它试图失败

#6  0x00007fddda9ec52d in printExceptionAndFree () from /opt/cloudera/parcels/CDH/lib64/libhdfs.so.0.0.0
#7  0x00007fddda9ed46b in getJNIEnv () from /opt/cloudera/parcels/CDH/lib64/libhdfs.so.0.0.0

但是在尝试时挂起 printExceptionAndFreeV() - &gt; setTLSExceptionStrings() - &gt; mutexLock()锁..

1 个答案:

答案 0 :(得分:0)

发现根本原因是https://issues.apache.org/jira/browse/HDFS-11851

感谢。