RFR: 8328630: Add logging when needed symbols in dll are missing. [v2]

Robbin Ehn rehn at openjdk.org
Thu Mar 28 09:29:36 UTC 2024


On Mon, 25 Mar 2024 07:46:49 GMT, Robbin Ehn <rehn at openjdk.org> wrote:

>> Sorry Robbin can you just re-explain why we need the initial call to `dl_error` here please. If the `dl_sym` is successful then we shouldn't be checking `dl_error`; and if not successful then `dl_error` should be returning that most recent failure.
>
> Hey, David, sure.
> 
> The dl error string is only cleared by dlerror.
> It can be set by dlopen/dlsym/dlclose on error (but never cleared by these).
> If someone used any of these before your call and failed, skipped calling dlerror,
> there might be a pending error string.
> 
> dlsym returns NULL on ERROR, but the value of a symbol may also be NULL.
> 
> This means we need to use both dlerror return value plus dlsym return value to figure out what was going on.
> dlsym = NULL, dlerror = NULL   => symbol was NULL
> dlsym = NULL, dlerror = "error" => real error
> dlsym = pointer, dlerror = ignored = found usable symbol
> 
> "Since the value of the symbol could actually be NULL (so that a NULL return from dlsym() need not indicate an error), the correct way to test for an error is to call dlerror() to clear any old error conditions, then call dlsym(), and then call dlerror() again, saving its return value into a variable, and check whether this saved value is not NULL."

Make sense?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18404#discussion_r1542580219


More information about the hotspot-runtime-dev mailing list