Skip to content

Commit

Permalink
Document why RTLD_NODELETE is missing and why there is no .release() …
Browse files Browse the repository at this point in the history
…method. Add info on possible workaround and what to do if it does not help

Closes #74
Closes #68
  • Loading branch information
apolukhin committed Jan 16, 2025
1 parent e2ca8d9 commit 753af61
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions doc/faq.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ stability by your own.
[pre
]

* [*Question:] Is there a `RTLD_NODELETE` mode? Is there a built in way to skip unload or "leak" a dynamically loaded library?
* [*Answer:] No. Boost tries to support best practices and leaking resources is not one of them. If you are dynamically loading a third party library that fails to unload, try the following:
```
std::vector<boost::dll::shared_library>& late_unload_registry() {
static std::vector<boost::dll::shared_library> registry;
return registry;
}
```
and push the library to that registry `late_unload_registry().emplace_back(third_party_shared_library)`. It will force the library to not unload till the end of program.

If the above `late_unload_registry()` does not help - ask the vendor of the library for support to dynamically load/unload the library.

[pre
]

* [*Question:] How to load a shared object from memory??
* [*Answer:] All existing OS avoid loading shared libraries directly from userspace memory, so you'll find no syscall for such case. Currently Boost.DLL provides no means for honest loading shared objects from memory. This requires reimplementing dynamic linker logic in userspace for all the platforms, which is a huge amount of work and very error-prone. However working patches are welcomed!

Expand Down

0 comments on commit 753af61

Please sign in to comment.