Skip to content

gh-160388: Load the copied library in the deleted-mapping test - #160396

Merged
itamaro merged 1 commit into
python:mainfrom
zanieb:zb/deleted-libpython-test-upstream
Oct 23, 2026
Merged

itamaro merged 1 commit into
python:mainfrom
zanieb:zb/deleted-libpython-test-upstream

Conversation

@zanieb

@zanieb zanieb commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

The deleted-libpython mapping test uses LD_LIBRARY_PATH to load a temporary copy of the library. On glibc, an interpreter's DT_RPATH can take precedence and load a different copy, so the test fails because the temporary copy was not mapped. Preload the temporary library explicitly so the subprocess maps the file that the test removes. Create the copy beneath the working directory and preload it through a relative path, since LD_PRELOAD treats spaces and colons as separators.

Fixes #160388.

@itamaro itamaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why cpython itself doesn't (currently) set RPATH (so doesn't suffer from this issue), this fix doesn't regress anything for cpython itself, while making it easier to test by downstream distributors that do set RPATH. this change also makes the behavior consistent under glibc and musl when RPATH is set, because LD_PRELOAD would always win (although potentially loading two copies under musl), while LD_LIBRARY_PATH wins over RPATH only under musl.

@itamaro
itamaro merged commit 3a440b6 into python:main Oct 23, 2026
64 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @zanieb for the PR, and @itamaro for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 23, 2026

Copy link
Copy Markdown

GH-160515 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 23, 2026
@bedevere-app

bedevere-app Bot commented Oct 23, 2026

Copy link
Copy Markdown

GH-160516 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 23, 2026
itamaro pushed a commit that referenced this pull request Oct 23, 2026
…GH-160396) (#160515)

gh-160388: Load the copied library in the deleted-mapping test (GH-160396)

The deleted-`libpython` mapping test uses `LD_LIBRARY_PATH` to load a temporary copy of the library. On glibc, an interpreter's `DT_RPATH` can take precedence and load a different copy, so the test fails because the temporary copy was not mapped. Preload the temporary library explicitly so the subprocess maps the file that the test removes. Create the copy beneath the working directory and preload it through a relative path, since `LD_PRELOAD` treats spaces and colons as separators.
(cherry picked from commit 3a440b6)

Co-authored-by: Zanie Blue <contact@zanie.dev>
itamaro pushed a commit that referenced this pull request Oct 23, 2026
…GH-160396) (#160516)

gh-160388: Load the copied library in the deleted-mapping test (GH-160396)

The deleted-`libpython` mapping test uses `LD_LIBRARY_PATH` to load a temporary copy of the library. On glibc, an interpreter's `DT_RPATH` can take precedence and load a different copy, so the test fails because the temporary copy was not mapped. Preload the temporary library explicitly so the subprocess maps the file that the test removes. Create the copy beneath the working directory and preload it through a relative path, since `LD_PRELOAD` treats spaces and colons as separators.
(cherry picked from commit 3a440b6)

Co-authored-by: Zanie Blue <contact@zanie.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_remote_exec_deleted_libpython can fail when DT_RPATH selects libpython

2 participants