Date: Tue, 11 May 2021 22:52:10 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 255698] dlerror() returns non-NULL after a successful call to dlopen()/dlsym() Message-ID: <bug-255698-227-AlHngC76sb@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-255698-227@https.bugs.freebsd.org/bugzilla/> References: <bug-255698-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D255698 --- Comment #6 from Eugene M. Kim <astralblue@gmail.com> --- As for the dlsym() case you asked, I must have been mistaken, because I mys= elf could not reproduce the case (before the world build). Program used: #include <dlfcn.h> #include <stdarg.h> #include <stdio.h> #define PRINT_DLERROR() do { \ char const *err =3D dlerror(); \ printf("dlerror()=3D%p", err); \ if (err) printf(" (%s)", err); \ printf("\n"); \ } while (0) void test_dlsym(char const *path, ...) { va_list va; void *handle =3D dlopen(path, RTLD_NOW); char const *symbol; void *addr; printf("dlopen(%s, RTLD_NOW)=3D%p\n", path, handle); PRINT_DLERROR(); PRINT_DLERROR(); va_start(va, path); while ((symbol =3D va_arg(va, char const *)) !=3D NULL) { addr =3D dlsym(handle, symbol); printf("dlsym(%s, %s) =3D %p\n", path, symbol, addr); PRINT_DLERROR(); PRINT_DLERROR(); } if (handle) dlclose(handle); } int main() { PRINT_DLERROR(); PRINT_DLERROR(); test_dlsym("/foobar.so", 0); test_dlsym("/usr/lib/libm.so", "omgwtf", "sqrt", 0); return 0; } Output: dlerror()=3D0x800222770 () dlerror()=3D0x0 dlopen(/foobar.so, RTLD_NOW)=3D0x0 dlerror()=3D0x800222770 (Cannot open "/foobar.so") dlerror()=3D0x0 dlopen(/usr/lib/libm.so, RTLD_NOW)=3D0x800226808 dlerror()=3D0x800222770 (Cannot open "/foobar.so") dlerror()=3D0x0 dlsym(/usr/lib/libm.so, omgwtf) =3D 0x0 dlerror()=3D0x800222770 (Undefined symbol "omgwtf") dlerror()=3D0x0 dlsym(/usr/lib/libm.so, sqrt) =3D 0x8006a3900 dlerror()=3D0x0 dlerror()=3D0x0 (Note the first dlerror() after dlsym(libm.so, sqrt) correctly returned NUL= L.=20 I thought I had seen a non-NULL message here; it seems my memory defied me. :-p) --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-255698-227-AlHngC76sb>