The Java VM crash with a SIGSEGV in a docker container. On all other systems it is working as expected.
# 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
and the stack trace
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$1.opj_read_header(Ljnr/ffi/Pointer;Ljnr/ffi/Pointer;Ljnr/ffi/byref/PointerByReference;)Z+190
What can I do to solve this problem with jffi / jnr? How can I receive more details about the problem?
Advertisement
Answer
The cause of the crash on Linux was a inkompatible native libraries for the target OS. The native library was compiled with glibc
and the OS with the crash use musl
. It was not a bug in any of the libraries.
To solve the problem we bundle now a second version of the library. And differ with the follow code:
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-" );
More details are in the issue comments: https://github.com/dbmdz/imageio-jnr/issues/192
Open is the question why loadLibrary
not throw an error or how an Java developer can find it.