Bug 256105

Summary: dlerror(3) returns an empty string
Product: Base System Reporter: Yuri Victorovich <yuri>
Component: miscAssignee: Yuri Victorovich <yuri>
Status: Closed Works As Intended    
Severity: Affects Only Me CC: kib
Priority: ---    
Version: 13.0-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
dlerror-return.c none

Description Yuri Victorovich freebsd_committer 2021-05-23 18:18:07 UTC
Created attachment 225202 [details]
dlerror-return.c

The attached program prints this:
> after dlopen of '/usr/lib/libutil.so' dlerror: p=0x800222760 s='' s[0]=0

dlerror(3) returns an empty, zero-terminated string.

The manpage says that it returns null pointer when no error has occurred:
>      The dlerror() function returns a null-terminated character string
>      describing the last error that occurred during a call to dlopen(),
>      dladdr(), dlinfo(), dlsym(), dlvsym(), dlfunc(), or dlclose().  If no
>      such error has occurred, dlerror() returns a null pointer.  At each call
>      to dlerror(), the error indication is reset.  Thus in the case of two
>      calls to dlerror(), where the second call follows the first immediately,
>      the second call will always return a null pointer.

Was the behavior changes?

I found this problem while investigating why the Jack audio server (audio/jack) now fails to start with:
> could not find any drivers in /usr/local/lib/jack!

This is because its test for errors fails because of the above.
Comment 1 Yuri Victorovich freebsd_committer 2021-05-23 18:19:39 UTC
stable/13-n245681-e2a49768a4a : Tue May 18 21:45:23 PDT 2021
Comment 2 Konstantin Belousov freebsd_committer 2021-05-23 18:23:35 UTC
There was a bug in 4d9128da54f8f8e2a, fixed in 630caa95d46191220dd4.
Corresponding stable/13 revisions are 7bbfb5d959329f and 29b896e67ddb05.

I cannot reproduc your issue on today stable/13.
Comment 3 Yuri Victorovich freebsd_committer 2021-05-23 18:25:38 UTC
(In reply to Konstantin Belousov from comment #2)

Ok, I rebuilt it only 4 days ago. I will rebuild again.
Comment 4 Yuri Victorovich freebsd_committer 2021-05-23 22:36:52 UTC
The problem was intermittent and is now gone, as Konstantin said.