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

Try to respect RPATHS of calling dlopen modules with dlinfo #549

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pablogsal
Copy link
Member

This commit is just for backup on our main strategy of using dlinfo
instead of dlopen.

Issue number of the reported bug or feature request: #

Describe your changes
A clear and concise description of the changes you have made.

Testing performed
Describe the testing you have performed to ensure that the bug has been addressed, or that the new feature works as planned.

Additional context
Add any other context about your contribution here.

@codecov-commenter
Copy link

codecov-commenter commented Feb 13, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (41248ed) 92.55% compared to head (60846e3) 92.83%.
Report is 16 commits behind head on main.

Files Patch % Lines
src/memray/reporters/tree.py 72.72% 3 Missing ⚠️
src/memray/_memray/hooks.cpp 95.45% 2 Missing ⚠️
tests/integration/test_extensions.py 90.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #549      +/-   ##
==========================================
+ Coverage   92.55%   92.83%   +0.28%     
==========================================
  Files          91       91              
  Lines       11304    11153     -151     
  Branches     1581     2024     +443     
==========================================
- Hits        10462    10354     -108     
+ Misses        837      799      -38     
+ Partials        5        0       -5     
Flag Coverage Δ
cpp 92.83% <91.66%> (+6.89%) ⬆️
python_and_cython 92.83% <91.66%> (-2.89%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This commit is just for backup on our main strategy of using dlinfo
instead of dlopen.

Signed-off-by: Pablo Galindo <[email protected]>
Comment on lines +342 to +344
if (name == nullptr || name[0] == '\0') {
continue;
}
Copy link
Contributor

@godlygeek godlygeek Feb 13, 2024

Choose a reason for hiding this comment

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

I don't think this is correct - an empty entry is relative to $PWD, and skipping over that entry but continuing to search other directories after it might mean we load the wrong file.

Comment on lines +326 to +330
if (stat(dlname, &dlstat) == 0 && stat("/proc/self/exe", &exestat) == 0
&& dlstat.st_dev == exestat.st_dev && dlstat.st_ino == exestat.st_ino)
{
dlname = nullptr;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is potentially error prone - it'll miss the case where the executable has been unlinked, at least (/proc/self/exe is a broken symlink in that case).

What if we instead checked if dladdr(dlsym(dlopen(nullptr), "main")) has the same dli_fname as dladdr(callerAddr)?

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.

None yet

3 participants