https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255698

--- Comment #6 from Eugene M. Kim <[email protected]> ---
As for the dlsym() case you asked, I must have been mistaken, because I myself
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 = dlerror(); \
        printf("dlerror()=%p", err); \
        if (err) printf(" (%s)", err); \
        printf("\n"); \
} while (0)

void
test_dlsym(char const *path, ...)
{
        va_list va;
        void *handle = dlopen(path, RTLD_NOW);
        char const *symbol;
        void *addr;
        printf("dlopen(%s, RTLD_NOW)=%p\n", path, handle);
        PRINT_DLERROR();
        PRINT_DLERROR();
        va_start(va, path);
        while ((symbol = va_arg(va, char const *)) != NULL) {
                addr = dlsym(handle, symbol);
                printf("dlsym(%s, %s) = %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()=0x800222770 ()
dlerror()=0x0
dlopen(/foobar.so, RTLD_NOW)=0x0
dlerror()=0x800222770 (Cannot open "/foobar.so")
dlerror()=0x0
dlopen(/usr/lib/libm.so, RTLD_NOW)=0x800226808
dlerror()=0x800222770 (Cannot open "/foobar.so")
dlerror()=0x0
dlsym(/usr/lib/libm.so, omgwtf) = 0x0
dlerror()=0x800222770 (Undefined symbol "omgwtf")
dlerror()=0x0
dlsym(/usr/lib/libm.so, sqrt) = 0x8006a3900
dlerror()=0x0
dlerror()=0x0

(Note the first dlerror() after dlsym(libm.so, sqrt) correctly returned NULL. 
I thought I had seen a non-NULL message here; it seems my memory defied me.
:-p)

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to