rust-dlopen
rust-dlopen copied to clipboard
`dlerror` *is* thread-safe on some platforms
I can see in the source code that there's a global lock for dlerror, since this crate assumes that it's not thread-safe. However, the manuals for Linux and macOS do indicate that their implementation is thread-safe:
- https://man7.org/linux/man-pages/man3/dlerror.3.html#ATTRIBUTES
- https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dlerror.3.html
Perhaps that lock could only be used on platforms other than these (or any more that might come up).
Also, the table about libloading not being thread-safe is slightly wrong, AFAIK (https://docs.rs/dlopen/0.1.8/dlopen/#compare-with-other-libraries). Internally, libloading uses SetThreadErrorMode (maybe it didn't in the past), which means that it's thread safe on Windows. The issue it has is that on FreeBSD, for example, dlerror isn't thread-safe.
I implemented this in my fork dlopen2