Repository navigation
Resolve dlsym(..., "errno") to the calling thread's errno - #20
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.
glibc's libc exports errno itself, a TLS object, and dlsym resolves it to
the calling thread's instance. Compiled code goes through
__errno_location, but foreign function interfaces reach the variable by
name: LuaJIT's lib/ffi/redir.lua test declares `int redir_bar
asm("errno")` and writes to it through ffi.C. musl has no such symbol, so
under the bridge the lookup failed with "symbol not found".
dlsym now falls back to musl's errno of the calling thread when nothing
else defines the name.
The conformance battery checks that dlsym(RTLD_DEFAULT, "errno") is
&errno.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
buyemune-sys
force-pushed
the
fix/dlsym-errno
branch
from
October 20, 2026 08:11
cf24e99 to
828e89c
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
glibc's libc exports
errnoitself, a TLS object, anddlsymresolves it to the calling thread's instance. Compiled code goes through__errno_location, but foreign function interfaces reach the variable by name. LuaJIT'slib/ffi/redir.luadeclaresint redir_bar asm("errno")and writes to it throughffi.C. musl has no such symbol, so under the bridge the lookup failed:The fix
When nothing else defines the name,
dlsymfalls back to musl's errno of the calling thread (lib/glibc_shim.cpp:4727).Test
The conformance battery checks that
dlsym(RTLD_DEFAULT, "errno") == &errno.On
mainthe check fails. With the fix:./build testpasses.