如何使用 jffi/jnr 处理 SIGSEGV?
How to handle a SIGSEGV with jffi / jnr?
Java VM 在 docker 容器中因 SIGSEGV 崩溃。在所有其他系统上,它都按预期工作。
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000000007966, pid=188, tid=189
#
# JRE version: OpenJDK Runtime Environment Temurin-17.0.2+8 (17.0.2+8) (build 17.0.2+8)
# Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (17.0.2+8, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C 0x0000000000007966
和堆栈跟踪
Current thread (0x00007fbdfa103040): JavaThread "main" [_thread_in_native, id=189, stack(0x00007fbdff179000,0x00007fbdff279ac8)]
Stack: [0x00007fbdff179000,0x00007fbdff279ac8], sp=0x00007fbdff277c38, free space=1019k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0x0000000000007966
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.kenai.jffi.Foreign.invokeN3O1(JJJJJLjava/lang/Object;III)J+0
j com.kenai.jffi.Invoker.invokeN3(Lcom/kenai/jffi/CallContext;JJJJILjava/lang/Object;Lcom/kenai/jffi/ObjectParameterStrategy;Lcom/kenai/jffi/ObjectParameterInfo;Ljava/lang/Object;Lcom/kenai/jffi/ObjectParameterStrategy;Lcom/kenai/jffi/ObjectParameterInfo;Ljava/lang/Object;Lcom/kenai/jffi/ObjectParameterStrategy;Lcom/kenai/jffi/ObjectParameterInfo;)J+126
j de.digitalcollections.openjpeg.lib.libopenjp2$jnr$ffi.opj_read_header(Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;Ljnr/ffi/byref/PointerByReference;)Z+190
我该如何解决 jffi / jnr 的这个问题?我怎样才能收到有关该问题的更多详细信息?
Linux 崩溃的原因是目标 OS 的本机库不兼容。本机库使用 glibc
编译,OS 崩溃使用 musl
。这不是任何库中的错误。
为了解决这个问题,我们现在捆绑了第二个版本的库。与以下代码不同:
ProcessBuilder builder = new ProcessBuilder( "ldd", "/bin/ls" );
Process process = builder.start();
InputStream input = process.getInputStream();
process.waitFor( 5, TimeUnit.SECONDS );
String content = new String( input.readAllBytes() );
LogManager.getConfigLogger().debug( content );
boolean isMuslLibrary = content.contains( "musl-" );
更多细节在问题评论中:https://github.com/dbmdz/imageio-jnr/issues/192
开放的问题是为什么 loadLibrary
不抛出错误或 Java 开发人员如何找到它。
Java VM 在 docker 容器中因 SIGSEGV 崩溃。在所有其他系统上,它都按预期工作。
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000000007966, pid=188, tid=189
#
# JRE version: OpenJDK Runtime Environment Temurin-17.0.2+8 (17.0.2+8) (build 17.0.2+8)
# Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (17.0.2+8, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C 0x0000000000007966
和堆栈跟踪
Current thread (0x00007fbdfa103040): JavaThread "main" [_thread_in_native, id=189, stack(0x00007fbdff179000,0x00007fbdff279ac8)]
Stack: [0x00007fbdff179000,0x00007fbdff279ac8], sp=0x00007fbdff277c38, free space=1019k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C 0x0000000000007966
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.kenai.jffi.Foreign.invokeN3O1(JJJJJLjava/lang/Object;III)J+0
j com.kenai.jffi.Invoker.invokeN3(Lcom/kenai/jffi/CallContext;JJJJILjava/lang/Object;Lcom/kenai/jffi/ObjectParameterStrategy;Lcom/kenai/jffi/ObjectParameterInfo;Ljava/lang/Object;Lcom/kenai/jffi/ObjectParameterStrategy;Lcom/kenai/jffi/ObjectParameterInfo;Ljava/lang/Object;Lcom/kenai/jffi/ObjectParameterStrategy;Lcom/kenai/jffi/ObjectParameterInfo;)J+126
j de.digitalcollections.openjpeg.lib.libopenjp2$jnr$ffi.opj_read_header(Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;Ljnr/ffi/byref/PointerByReference;)Z+190
我该如何解决 jffi / jnr 的这个问题?我怎样才能收到有关该问题的更多详细信息?
Linux 崩溃的原因是目标 OS 的本机库不兼容。本机库使用 glibc
编译,OS 崩溃使用 musl
。这不是任何库中的错误。
为了解决这个问题,我们现在捆绑了第二个版本的库。与以下代码不同:
ProcessBuilder builder = new ProcessBuilder( "ldd", "/bin/ls" );
Process process = builder.start();
InputStream input = process.getInputStream();
process.waitFor( 5, TimeUnit.SECONDS );
String content = new String( input.readAllBytes() );
LogManager.getConfigLogger().debug( content );
boolean isMuslLibrary = content.contains( "musl-" );
更多细节在问题评论中:https://github.com/dbmdz/imageio-jnr/issues/192
开放的问题是为什么 loadLibrary
不抛出错误或 Java 开发人员如何找到它。