[Bug 255698] dlerror() returns non-NULL after a successful call to dlopen()/dlsym()
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sat May 8 07:10:55 UTC 2021
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255698
Bug ID: 255698
Summary: dlerror() returns non-NULL after a successful call to
dlopen()/dlsym()
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: bin
Assignee: bugs at FreeBSD.org
Reporter: astralblue at gmail.com
dlerror() used to return NULL after a successful call to other dl family of
functions, such as dlopen() and dlsym(). Starting recently, dlerror() started
returning non-NULL message after such successful calls. The message is
initially an empty string, or an error message most recently seen—even if the
most recent dlXXXX() call was successful.
Test program:
#include <dlfcn.h>
#include <stdio.h>
#define PRINT_DLERROR() do { \
char const *err = dlerror(); \
printf("dlerror()=%p", err); \
if (err) printf(" (%s)", err); \
printf("\n"); \
} while (0)
void
test_dlopen(char const *path)
{
void *handle = dlopen(path, RTLD_NOW);
printf("dlopen(%s, RTLD_NOW)=%p\n", path, handle);
PRINT_DLERROR();
PRINT_DLERROR();
if (handle)
dlclose(handle);
}
int
main()
{
PRINT_DLERROR();
PRINT_DLERROR();
test_dlopen("/foobar.so");
test_dlopen("/usr/lib/libm.so");
return 0;
}
Expected result (taken on a 12.2-RELEASE-p2 jail, note dlerror() returns NULL
upon a successful dlopen()):
dlerror()=0x0
dlerror()=0x0
dlopen(/foobar.so, RTLD_NOW)=0x0
dlerror()=0x8002296c0 (Cannot open "/foobar.so")
dlerror()=0x0
dlopen(/usr/lib/libm.so, RTLD_NOW)=0x80022e800
dlerror()=0x0
dlerror()=0x0
Actual result (taken on a -CURRENT system, built from main branch commit
34abb05be77a32a2b2673fb4b85eaa53a3d1446e, note dlerror() returns non-NULL on
the first dlerror() call, even after a successful dlopen() and also before the
first dlopen(), also note the dlerror() message after a successful dlopen() is
from the previous failure):
34abb05be77a32a2b2673fb4b85eaa53a3d1446e
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list