Repository navigation
Check that optional native libraries exist before loading them on AIX, OpenBSD and DragonFly BSD - #3782
Merged
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📜 Recent review details
📝 Walkthrough
|
Follow-up to #3776. The Solaris/illumos crash in #3775 is not unique to illumos:
dlerror()state is process-wide on Solaris/illumos, AIX, NetBSD, DragonFly BSD and OpenBSD, and per-thread only on glibc, macOS and FreeBSD. JNA'sLOAD_ERRORreads the message with an unguardedstrlen/strcpy, so a faileddlopenracing another thread's faileddlsym(or the JVM's owndlerrorcalls) can crash.This extends
NativeLibraryUtil.isSafeToLoadfrom Solaris-only to AIX, OpenBSD and DragonFly BSD, so an optional library that is not installed is never loaded. All logic stays inoshi-common; the JNA and FFM call sites already used the shared check and only have comment changes.Per-platform rules:
LD_LIBRARY_PATHplus the linker's default directories; a versioned file (libcups.so.7.3) counts, since the linker resolves the unversioned name to it. OpenBSD ships only versioned names.LIBPATH(orLD_LIBRARY_PATHwhen it is unset),/usr/lib,/lib. An archive name never counts, because an archive loads only by naming a member, which neither backend supplies. JNA mapscupstolibcups.aon AIX, soCupsPrinterJNApasses that name and never attempts the load.Verification
dlerroron each Unix (AIX and Solaris live; the BSDs on CI VMs).Native.loadon a missing library, half failgetFunctionon a missing symbol, 4 threads, 60 s):libc strlen+0x30, the same frame as the CI crash.Java_com_sun_jna_Native_open.Not covered: directories added only through linker configuration (
ldconfighints,/etc/ld.so.conf); a library found only there is reported absent and the caller falls back to its command-line path.Separately found: OSHI's JNA libcups load can never succeed on AIX, because AIX loads an archive only with a member name. AIX printers have always come from
lpstat. Deferred to after 7.7.1.Summary by CodeRabbit