bell-sw / Liberica

Free and 100% open source Progressive Java Runtime for modern Java™ deployments supported by a leading OpenJDK contributor
https://bell-sw.com/pages/libericajdk/
GNU General Public License v2.0
318 stars 29 forks source link

Crash when using native library embedded in a jar. #163

Closed DavidPerezIngeniero closed 8 months ago

DavidPerezIngeniero commented 8 months ago

When using this Java library org.sejda.imageio:webp-imageio:0.1.6, https://github.com/sejda-pdf/webp-imageio, I observe that it always crashes:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000000000b8e6, pid=1202, tid=1252
#
# JRE version: OpenJDK Runtime Environment (21.0.2+14) (build 21.0.2+14-LTS)
# Java VM: OpenJDK 64-Bit Server VM (21.0.2+14-LTS, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [9016979929944388058libwebp-imageio.so+0x4afde]
#
# Core dump will be written. Default location: /sv/servision/core.1202
#
# An error report file with more information is saved as:
# /sv/servision/hs_err_pid1202.log
[943.253s][warning][os] Loading hsdis library failed
#
# If you would like to submit a bug report, please visit:
#   https://bell-sw.com/support
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.

If needed, I can provide the full log file.

I've experience some years ago the same behaviour. I had switched with a Docker image with exactly the same JVM version, but compiled differently, and the problem disappears.

This is the only issue I've found when trying Bellsoft.

The exact image I've tried is: bellsoft/liberica-openjdk-alpine-musl:21.0.2-cds

DavidPerezIngeniero commented 8 months ago

I confirm that only the musl version crashes, the glibc doesn't.

voitylov commented 8 months ago

It might easily happen that the shared object inside the jar was only compiled for glibc. You can check if this is the case by running ldd on the .so files in the jar:

ldd libwebp-imageio.so

and see if it complains.

The fact that there are some jars that still don't include .so for musl based systems was the primary motivation for providing both musl and glibc based Alpaquita, on which liberica-runtime-container is based.