Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the handle from dlopen and not from debug infos #143

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

alkino
Copy link

@alkino alkino commented Feb 11, 2024

Should fix #142

You should look twice and understand it twice before merge (we are out of my competences).

There is 2 different link_map, one is internal and seen in the API only as void* returned by dlopen() and used as first argument by dlsym().
The other one is public but is used for debugging purpose.

@@ -161,7 +162,8 @@ static void *dlsym_wrapper(void *handle, const char *symbol_name) {
struct link_map *lib = gotchas_dlsym_rtld_next_lookup(
symbol_name, __builtin_return_address(0));
if (lib) {
void *symbol = orig_dlsym(lib, symbol_name);
void *handle = orig_dlopen(lib->l_name, RTLD_NOW);
Copy link
Author

Choose a reason for hiding this comment

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

I have a doubt between RTLD_NOW and RTLD_LAZY

Copy link
Member

@hariharan-devarajan hariharan-devarajan left a comment

Choose a reason for hiding this comment

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

The changes look good. The idea is to use the same internal struct of link_map so that on some kernels this doesn't fail.

@hariharan-devarajan hariharan-devarajan merged commit a449eba into LLNL:develop Feb 28, 2024
4 checks passed
@alkino alkino deleted the cornu/fix_dlopen branch November 14, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gotcha segfaults in Caliper-annotated code when finalizing Python
2 participants