dlopen()/dlsym()/dlerror() was: Re: libXcursor.so.1.0.2 reference in libX11.so.6 ??

From: Igor Robul (igorr_at_speechpro.com)
Date: 10/31/05

  • Next message: George Katsanos: "Freebsd / FireFox / Macromedia Flash : The Quest"
    Date: Mon, 31 Oct 2005 15:42:54 +0300
    To: Rob <spamrefuse@yahoo.com>, freebsd-questions@freebsd.org
    
    

    Rob wrote:

    >>
    >>So you can see, from where we got 1.0.2
    >>
    >>
    >>
    >
    >
    >Yes, indeed, very true.
    >It's Xorg that has this library version hardcoded.
    >
    >Meanwhile, I also found out following:
    >
    >On FreeBSD, the dl* functions do not reset a
    >previous error indicator. In this specific case,
    >in xc/lib/X11/CrGlCur.c Xorg will first try to
    >"dlopen" the library libXcursor.so.1.0.2 without
    >success (this will set the dlerror indicator),
    >next Xorg will try to dlopen libXcursor.so.1.0
    >without success (again sets dlerror indicator), but
    >eventually successfully dlopens libXcursor.so.1.
    >However, the last successful dlopen call does NOT
    >clear the earlier dlerror indicator.
    >
    >
    dlerror() resets error indicator. From /usr/src/libexec/rtld-elf/rtld.c:

    const char *
    dlerror(void)
    {
        char *msg = error_message;
        error_message = NULL;
        return msg;
    }

    Error indicator is not reseted by successful call to dlopen(), but I'm
    not sure that dlopen() need reset error
    indicator. At least I could not find information about this in manual page.

    >Conclusively:
    >The whole library problem boils down to the
    >behaviour of the dl* functions, with respect to
    >the clearing/setting the dlerror indicator.
    >In general, one should always call dlerror() prior
    >to the use of the dl* functions, to clear any
    >previous dlerror indicator:
    >
    > dlerror(); /* clear previous error*/
    >
    > handle = dlopen("blabla.lib", RTLD_LAZY)
    > if ( !handle ) {
    > error_print(dlerror());
    > return FAILURE;
    > }
    >
    > data = dlsym(....);
    > error = dlerror();
    > if ( !data && error != NULL ) {
    > error_print(error);
    > return FAILURE;
    > }
    >
    > etc. etc.
    >
    >Note that a dlerror() call always will clear any
    >previous dlerror indicator.
    >
    >Does all that make sense to you?
    >
    >
    Yes.
    Is there any standart which describes dl*() functions? Because from _my_
    point of view
    dlopen()/dlsym() need not clear error indicator on success,
    dlopen()/dlsym() need to return NULL
    on error. dlerror() is one who can/have to clear error indicator.

    _______________________________________________
    freebsd-questions@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"


  • Next message: George Katsanos: "Freebsd / FireFox / Macromedia Flash : The Quest"