gpt4 book ai didi

Linux 上的 Java System.loadLibrary 调用卡住

转载 作者:太空宇宙 更新时间:2023-11-04 09:08:02 25 4
gpt4 key购买 nike

我有一个非常小的 .so 文件(可在此处获取:https://docs.google.com/leaf?id=0B4MxFm-ACB3INjhkMjhlNzktYzkxYy00Zjk5LTk0Y2MtZDE2MWQ2MzY1OWUy&hl=en_US&authkey=CMrJguwN)

我正在尝试将它加载到 RHEL 上的 Java 中,而 Java main 只是卡住(没有错误或异常)。我在 LD_LIBRARY_PATH 上有包含 .so 文件的目录,所以我知道它实际上正在尝试加载它。

有什么办法解决这个问题吗?

public class SmallTester {


public static void main(String[] args){

for(String s: System.getenv("LD_LIBRARY_PATH").split(":")){
System.out.println(s);
}

System.loadLibrary("TestAda");

System.out.println("Here");
}
}

编辑:

根据下面的帖子,我做了一个 strace.. 看起来它一遍又一遍地重复这个调用(我不确定这是什么意思?):

[pid 31464] clock_gettime(CLOCK_MONOTONIC, {3605675, 624255544}) = 0
[pid 31464] gettimeofday({1306417113, 168967}, NULL) = 0
[pid 31464] clock_gettime(CLOCK_MONOTONIC, {3605675, 624435576}) = 0
[pid 31464] clock_gettime(CLOCK_MONOTONIC, {3605675, 624518205}) = 0
[pid 31464] gettimeofday({1306417113, 169216}, NULL) = 0
[pid 31464] clock_gettime(CLOCK_REALTIME, {1306417113, 169306590}) = 0
[pid 31464] futex(0x88b3f04, FUTEX_WAIT_PRIVATE, 1, {0, 49909410}) = -1 ETIMEDOUT (Connection timed out)

这是日志的完整版本:https://docs.google.com/leaf?id=0B4MxFm-ACB3IYzdhZWIwNWEtYjUzMS00NGM5LWEzZjQtYzMzOWE3MWNhYWQ0&hl=en_US&authkey=CJ-Lv_wG

EDIT2:我也尝试用 JNA 加载库:

public class SmallTesterJNA {

public interface CLibrary extends Library {

CLibrary INSTANCE1 = (CLibrary)
Native.loadLibrary("TestAda", // <<< our library goes here
CLibrary.class);

}

public static void main(String[] args){

for(String s: System.getenv("LD_LIBRARY_PATH").split(":")){
System.out.println(s);
}

System.loadLibrary(CLibrary.INSTANCE1.toString());

System.out.println("Here");
}
}

这是输出..它看起来非常相似:https://docs.google.com/leaf?id=0B4MxFm-ACB3IYzdhZWIwNWEtYjUzMS00NGM5LWEzZjQtYzMzOWE3MWNhYWQ0&hl=en_US&authkey=CJ-Lv_wG

编辑2:

这是附加到该过程的我的 gcore 输出。不确定这告诉我什么:

(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 0xb7fb26c0 (LWP 8326)]
[New Thread 0x7fa8eb90 (LWP 8340)]
[New Thread 0x7fe2db90 (LWP 8339)]
[New Thread 0x7fe7eb90 (LWP 8338)]
[New Thread 0x7feffb90 (LWP 8337)]
[New Thread 0x800afb90 (LWP 8336)]
[New Thread 0x80100b90 (LWP 8335)]
[New Thread 0x80351b90 (LWP 8334)]
[New Thread 0x803a2b90 (LWP 8333)]
[New Thread 0x80423b90 (LWP 8332)]
[New Thread 0x8066db90 (LWP 8331)]
[New Thread 0x806eeb90 (LWP 8330)]
[New Thread 0x8076fb90 (LWP 8329)]
[New Thread 0x807f0b90 (LWP 8328)]
[New Thread 0xb7474b90 (LWP 8327)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
0xb7fcd402 in __kernel_vsyscall ()
Saved corefile core.8326

最佳答案

如果非要我猜的话,我会说罪魁祸首可能是共享对象的初始化代码。

获取您的 JVM 进程的核心转储(使用 gcore)或附加 gdb 以获取它卡住的确切位置的堆栈跟踪。

关于Linux 上的 Java System.loadLibrary 调用卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6138982/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com