jni应用程序挂起

8nuwlpux  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(678)

请帮助您如何调试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调试问题?如果您感兴趣,这里有一段c代码,它跨越了jni交互的jvm-https://gist.github.com/tagar/7c42f82f5538004bda2f4ea0b0e0adc5
java版本“1.8.0_”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()->settlesExceptionString()->mutexlock()锁。。

juzqafwq

juzqafwq1#

根本原因是https://issues.apache.org/jira/browse/hdfs-11851
谢谢。

相关问题