-
Notifications
You must be signed in to change notification settings - Fork 1
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
Question regarding loading libraries on Unix systems #8
Comments
That said, minidl does effectively leak handles to all shared libraries loaded through it for the duration of the program by not supporting
Although I can't find a full rant / elaboration on why in these docs... so here goes! The simple act of loading a dynamic library may, via e.g. constructors:
Unloading out with any of this active is immediate undefined behavior (dangling pointers), limitations on DllMain / OS loader locks mean this typically cannot be sanely fixed via destructors, and the codepath is usually quite poorly tested - if tested at all.
I'm of the opinion that the proper thing to do is to simply leak the shared library.
|
I'm not a fan of leaving the hassle to the developer by forcing them to manually restarting the process or copy-pasting the library, but at least there is a reason behind it. I didn't know about I wonder if there might be another way to tackle it without causing issues. Anyway, thank you for taking your time to make such an exhaustive explanation! I really appreciate it. |
Apparently my previous ranting on the subject was in denying PR#5 |
Understandably,
dlopen
is used to retrieve the the starting address of a library. However, according to the documentation of the function and many other programs using it, usingdlopen
on an already loaded library will increment the reference count, which means that unrelated programs will have to usedlclose
as many times as it was opened by this library to successfully close it. This is the reason why, for such cases, adlopen
is always paired withdlclose
( here is an example ). MaybeRTLD_NOLOAD
could do the job, but I'm unsure if increments the reference count regardless.So I'm just wondering why it's not being done here, unless I've completely missed something obvious or the purpose of this library, in which case I'm sorry!
The text was updated successfully, but these errors were encountered: