Skip to content

Conversation

@no92
Copy link
Member

@no92 no92 commented Sep 24, 2025

This PR aims to have the dynamic linker tolerate failures in opening a shared object, in which case it should continue going down its list of paths to find an appropriate shared object.

This can reasonably occur in the wild, as for instance RPATHs can point to broken shared objects. Alternatively, I have encountered the case on my machine (Fedora) where the first libgcc_s.so.1 found is actually for i386, which is rejected, and further down the list of library paths the x86_64 libgcc_s.so.1 is found.

@no92
Copy link
Member Author

no92 commented Oct 26, 2025

I'm not sure and can't test while not at home, but I think this might address the issue in #1431.

if(!result) {
if (verbose || stillSlightlyVerbose)
mlibc::infoLogger() << "rtld: failed to open " << name << frg::endlog;
frg::destruct(getAllocator(), object);
Copy link
Member

Choose a reason for hiding this comment

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

This could return a unique_ptr<SharedObject> to avoid the need for manual frg::destruct.

break;
auto rpathResult = processRpath(path);
if (rpathResult) {
res = trySharedObjectSetup(rpathResult.value().get<0>(), rpathResult.value().get<1>());
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't it make more sense to propagate the error if the open succeeds and the load fails? Basically, why don't we handle this like in the last case?

Comment on lines +358 to +359
if (rpathResult)
res = trySharedObjectSetup(rpathResult.value().get<0>(), rpathResult.value().get<1>());
Copy link
Member

Choose a reason for hiding this comment

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

Likewise.

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.

2 participants