Repository navigation
Conversation
… as not found (#96) A Python with a static INSTSONAME, e.g. conda-forge's libpython3.12.a, which it does not ship, now has its shared libpython taken from LIBDIR when the native library of Jep needs exactly one soname of the same version and ABI (DT_NEEDED, e.g. libpython3.12.so.1.0), and that file exists, so it is preloaded like any other. readElfDynamic parses the ELF dynamic section from the program headers, reading only the parts it needs. jepLoadsGlobally tells "not found" when libjep has a DT_RPATH or DT_RUNPATH, or its dynamic section cannot be read, and reads the dynamic section and the libpython name of Jep lazily, only after the loader finds the soname. The LD_PRELOAD advice now offers Java 22 with native access first, is conditional when Jep's libpython name is uncertain, and scopes LD_PRELOAD to the launch of the JVM, as its child processes inherit it. The README describes the conservative preload, the static libpython case and the default directories. The test of a library only in a default directory now reads a cache, and checks that listing the library would find it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG
…hild processes (#96) The README sent conda-forge users to LD_PRELOAD, while Jep compiles in the shared libpython3.12.so there, as the static library is missing, so the remedy is LIBDIR on LD_LIBRARY_PATH; LD_PRELOAD is left for a Jep built while libpython3.X.a existed. runProcess removes the libpython entries of LD_PRELOAD from the environment of the processes it starts, e.g. pip. The advice no longer tells to run on Java 22 when the JVM already is, but to enable native access, or not to disable the foreign linker. pythonLibrary does not take a shared soname which libjep does not need, when libjep needs another libpython. readElfDynamic caps the DT_NEEDED entries and the length of a string. loaderFinds also searches the directories of the RPATH of the java launcher, and the lib directory of java.home, which glibc searches before LD_LIBRARY_PATH for the libraries of libjep. The ELF library is read only on Linux. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG
loaderFinds returned true when the same file was in a directory of the JVM, though glibc might not search it for libjep, e.g. java.home/lib, or the RUNPATH of the executable, and ignored glibc-hwcaps there. Such a directory now only tells "not found", with another file of the name, also in its glibc-hwcaps, and the search goes on with LD_LIBRARY_PATH and the cache. $ORIGIN is expanded only as a whole token, any other $ cannot be told. runProcess filters only the inherited LD_PRELOAD, not one passed in its environment, and only of the names of a libpython of a Python version. The advice with the foreign linker enabled on Java 22 tells that it failed, and mentions --enable-native-access only if not already set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #96
Stacked on #97 (fix of #93) → #94 (#77) → #78 (#54) — merge #78, #94, #97, then this one (bottom-up, see CLAUDE.md).
Follow-ups of #93, with the same rule: a prediction may err towards "not found" (a harmless preload), never towards a wrong "found".
INSTSONAME(libpython3.X.a), so libpython was never preloaded nor advised. Now the shared library libjep actually needs is taken from libjep'sDT_NEEDED— only when exactly one same-stem.sois needed and that exact file is inLIBDIR(a conda-forge 3.12 package shipslib/libpython3.12.so.1.0, not the.a; not run end to end, no conda here). A shared soname libjep does not need gives "not found".readElfDynamic): read through the program headers like the loader (32/64-bit, both byte orders, stripped section headers), with caps on entries and string lengths; matchesreadelf -don every libjep build here (cp310–cp314), and survived every truncation and 30k random corruptions without an exception.RPATH/RUNPATH, or an unreadable one: "not found".RPATHof/proc/self/exe($ORIGINexpanded as a whole token) andjava.home/libcan only veto — a different file of the name there, also inglibc-hwcapssubdirectories, gives "not found"; they never make it "found".LD_PRELOAD: an inheritedlibpythonX.Y….soentry is no longer passed to the processes this library starts (the probe, pip); others are kept.--enable-native-access=ALL-UNNAMEDfirst); conditional when Jep's libpython name is only uncertain;LD_PRELOADonly for a Jep built whilelibpython3.X.aexisted.LD_LIBRARY_PATHwithLIBDIRon Java 17–21) and the static case.A system Python with its development symlink still gets no preload (checked on Java 17, 21, 22, 25); the real JDKs here get no spurious veto.
Review
3 rounds:
LD_PRELOAD(Jep compiles in the.sowhen the.ais absent) → fixed, plus advice and parser hardening.RUNPATH,java.home/lib,glibc-hwcaps) → it may only veto now.Left as polish: the KDoc calls the JVM directories a "superset" (a native launcher library with its own
RPATH, e.g. jpackage's, is not covered); the RPATH is decoded as ISO-8859-1, not the file system charset; a few older tests use the host JVM's real/proc/self/exe(would fail on a JDK with a relative or$LIBRPATH — passjvmDirectories = { emptyList() });${ORIGIN}_xgives "unknown" (preload);LD_PRELOADstill reaches subprocesses started from Python code (documented).🤖 Generated with Claude Code
https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG