Repository navigation
Conversation
Jep makes libpython global with dlopen of its development symlink (LDLIBRARY, e.g. libpython3.12.so). When the dynamic loader finds libpython by its soname but not that symlink, e.g. a system Python without libpython3.12-dev, the symbols stayed local, and a C extension not linked to libpython, like numpy's, failed with an undefined symbol. The probe now also reports LDLIBRARY, and libpython is preloaded with RTLD_GLOBAL (Java 22+) or made global in the first interpreter (Java 17-21) unless the loader finds both its soname and its development symlink as the same file (jepLoadsGlobally). A system Python with its development package is still left alone, so it gets no new restricted method warning on Java 22/23. PythonLibraryTest reproduces it with an LD_LIBRARY_PATH holding only the soname of the venv's libpython, failing before with a uv base Python. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG
#77) - The warning of makePythonLibraryGlobal no longer only advises LD_LIBRARY_PATH, which cannot help a Python of the system without its development package, now reaching the Java 17-21 path: it also advises installing the package providing LDLIBRARY (pythonLibraryGlobalAdvice). - jepLoadsGlobally reads /etc/ld.so.cache at most once for both names, and its finds seam takes only the name, the library being always the same. - PythonLibraryTest shares compiling the extension and running the JVM in withExtension and importExtension. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG
This was referenced Nov 13, 2026
Open
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 #77
Stacked on #78 (fix of #54) — merge #78 first, then this one (bottom-up, see CLAUDE.md).
When the dynamic loader finds
libpython3.X.so.1.0by itself (a system Python, orLD_LIBRARY_PATH), its symbols became global only by Jep's owndlopen("libpython3.X.so", RTLD_GLOBAL)of the development symlink — without it (e.g.libpython3.12-devnot installed) a C extension not linked to libpython (numpy, …) failed withundefined symbol.Now #54's
RTLD_GLOBALpreload also runs unless the loader finds both the soname and the development symlink, as the same file (jepLoadsGlobally) — so a system Python with its dev package stays untouched (no new foreign-linker warning on Java 22/23).LDLIBRARY(the development symlink name)./etc/ld.so.cacheis read once for both lookups..pth,sitecustomize) still needs the development symlink — README says so.Tests compile a C extension not linked to libpython and import it in a forked JVM whose
LD_LIBRARY_PATHholds only the soname: they fail without the fix on a uv CPython 3.13 base (undefined symbol: PyModule_AddStringConstant), and pass with it on Java 17, 22 and 25. With this machine's system Python they cannot reproduce the bug (its dev symlink is inld.so.cache), see DEVELOPMENT.md.Review
2 rounds:
Left as polish: the warning names
libpython3.X-devas a placeholder; the soname-only tests pass silently (not skipped) where the loader finds the dev symlink.Follow-ups
loaderFindspredictions differing from glibc/Jep (emptyLD_LIBRARY_PATHentry, musl/hwcaps, staticLDLIBRARY).🤖 Generated with Claude Code
https://claude.ai/code/session_01FJmHQ3jHRbVdpwUiNUkApG