Repository navigation
Keep a pending dlerror across lazy binding - #12
Open
buyemune-sys wants to merge 2 commits into
Open
buyemune-sys wants to merge 2 commits into
buyemune-sys wants to merge 2 commits into
Conversation
Security updates replaced libapparmor1 4.0.1really4.0.1-0ubuntu0.24.04.7 with .9 and libexpat1 2.6.1-2ubuntu0.4 with ubuntu0.6, and the pool kept only the new files, so the cold-cache Fetch x86_64 job answers 404 and every x86-64 job behind it is skipped. Both pins move to the versions noble-updates ships now; their SHA256s match the archive's Packages index. The other twelve pins are still served.
The lazy binder resolves through the bridge, whose lookups go through the public dl* entry points, and those reset the thread's error. A program that reads dlerror after a failed dlopen, with calls in between that happen to be first calls through the PLT, then got NULL. Tarantool does that when a C module fails to load: unlink and rmdir of its temporary copy run first, and the error reported became "(null)". ld.so's binding never touches dlerror. elfPltResolve now sets a pending error aside while it resolves and puts it back afterwards; with nothing pending it costs one thread-local check. The lazy-binding test library fails a dlopen and reads dlerror after a first call to getppid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
buyemune-sys
force-pushed
the
fix/lazy-binding-keeps-dlerror
branch
from
October 20, 2026 08:11
499a1cd to
179f848
Compare
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.
The problem
The lazy PLT resolver (
elfPltResolve,lib/elf_loader.cpp:2719) looks symbols up through the bridge, and the bridge goes through the publicstub_dlopen("c")/stub_dlsym, which reset the thread's error first. A program that readsdlerror()after a faileddlopen, with a first call to some function through the PLT in between, getsNULL.Example: when a C module fails to load, Tarantool calls
unlinkandrmdiron its temporary copy, and only thendlerror()(src/box/module_cache.c). Under solo the reason is lost:LD_DEBUG=dlfcnshows what happens after the faileddlopen:dlopen c/found unlink,dlopen c/found rmdir. Each of those clears the error.The fix
Binding never touches
dlerrorunder ld.so.elfPltResolvenow sets a pending error aside while it resolves and puts it back afterwards. With nothing pending, this costs one thread-local check.Test
tst/glibc_lazy_test.c(built with-z lazy) gainsglibc_lazy_dlerror_kept: a faileddlopen, then a first call togetppid, thendlerror(), which is itself bound lazily.main:lazy binding lost the pending dlerror: 3;./build testpasses.