fix: promote loader symbols to global scope before loading embedded.so (glibc)#524
Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits intomainfrom Mar 25, 2026
Conversation
Benchmark results for collatzParameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics. See unchanged results
|
Benchmark results for BadBoggleSolver_runParameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics. See unchanged results
|
…so (glibc) When libdd_profiling.so is dlopen'd with RTLD_GLOBAL, glibc defers symbol promotion until after dlopen returns. The inner dlopen of the embedded .so therefore cannot resolve ddprof_lib_state from the loader, causing it to fail silently. Fix: in the loader constructor, use RTLD_NOLOAD | RTLD_GLOBAL to re-open the loader itself and upgrade its binding to global before loading the embedded library. The soname is passed via DDPROF_LOADER_SONAME from CMake (defined when USE_LOADER is enabled). Guarded by #ifdef so the call is omitted in builds where USE_LOADER is not enabled. Note: dlopen with RTLD_GLOBAL is not supported on musl — musl rejects initial-exec TLS cross-library relocations for dlopen'd libraries. The test is skipped on musl and LD_PRELOAD is documented as the alternative. Add loader_rtld_global_test to verify the fix on glibc. Document the dlopen usage and musl limitation in Troubleshooting.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
nsavoire
reviewed
Mar 25, 2026
d80168d to
d8c67b6
Compare
nsavoire
reviewed
Mar 25, 2026
nsavoire
reviewed
Mar 25, 2026
- Clean up documentation - Remove the test which was moved to ddprof-build
nsavoire
approved these changes
Mar 25, 2026
Collaborator
Author
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
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.
What does this PR do?
When libdd_profiling.so is dlopen'd with RTLD_GLOBAL, glibc defers symbol promotion until after dlopen returns. The inner dlopen of the embedded .so therefore cannot resolve ddprof_lib_state from the loader, causing it to fail silently.
Fix: in the loader constructor, use RTLD_NOLOAD | RTLD_GLOBAL to re-open the loader itself and upgrade its binding to global before loading the embedded library. The soname is passed via DDPROF_LOADER_SONAME from CMake to avoid hardcoding.
Note: dlopen with RTLD_GLOBAL is not supported on musl — musl rejects initial-exec TLS cross-library relocations for dlopen'd libraries. The test is skipped on musl and LD_PRELOAD is documented as the alternative.
Add loader_rtld_global_test to verify the fix on glibc. Document the dlopen usage and musl limitation in Troubleshooting.md.
Motivation
see following issue
Additional Notes
We considered several approaches including removing the static tls approach.
How to test the change?
A test was added for the dlopen use case.
I will add a test in ddprof-build that handles: