RFR: JDK-8288003: log events for os::dll_unload [v5]

Thomas Stuefe stuefe at openjdk.java.net
Mon Jun 13 10:42:10 UTC 2022


On Mon, 13 Jun 2022 08:26:51 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

>> Currently we only log events for os::dll_load, but not for os::dll_unload, this patch adds it. On some platforms (Linux/Windows) we can use OS APIs (e.g. dlinfo on Linux) to log the path of the unloaded shared lib.
>
> Matthias Baesken has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Adjust dll_path

Hi Matthias,

this looks okay and is useful.

I worried a bit about the thread safety of ::dlerror(), since it is specified as not threadsafe by [Posix](https://pubs.opengroup.org/onlinepubs/009696799/functions/dlerror.html): "The dlerror() function need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe." . 

However, the glibc variant (https://sources.debian.org/src/glibc/2.28-10/dlfcn/dlerror.c) seems to be thread-safe, using POSIX TLS to store the resulting error string.

But interestingly enough, the string itself only lives as long as ::dlerror() is not called again. A second call to dlerror() will free() the string. So, one should use the string right away, for storing it should be strduped.

I did not look if dlerror is threadsafe on Muslc.

-------------

Marked as reviewed by stuefe (Reviewer).

PR: https://git.openjdk.org/jdk/pull/9101


More information about the hotspot-runtime-dev mailing list