[BRLTTY] dlsym/dlerror (was Re: Clumping all the braille driver modules into one big app?)
Willie Walker
William.Walker at Sun.COM
Fri Aug 29 08:17:52 EDT 2008
Thanks Dave! Given the below, this might actually turn into a one line
fix to call dlerror() just before calling dlsym(). That should clear
any existing error conditions and your existing code would continue to
work, I think.
Will
Dave Mielke wrote:
> [quoted lines by Willie Walker on 2008/08/28 at 20:58 -0400]
>
>> The problem is that brltty is jumping to dlerror too soon -- it should
>> first check the result of dlsym. The reason for this is that dlerror
>> returns the message for the _last failed_ dlsym, not the result of the
>> _last call_ to dlsym.
>
> There appears to be a philosophical difference between Solaris and Linux here.
> The Linux man page for dlsym() says the following:
>
> Since the value of the symbol could actually be NULL (so that a NULL return
> from dlsym() need not indicate an error), the correct way to test for an
> error is to call dlerror() to clear any old error conditions, then call
> dlsym(), and then call dlerror() again, saving its return value into a
> variable, and check whether this saved value is not NULL.
>
>> Internally, the Sun C library is doing some magic, which results in a
>> caught/expected failure on the _ex_unwind symbol. The change above checks the
>> result of the call to dlsym before jumping directly to dlerror.
>>
>> I hope you guys can accept this change!
>
> Yes, it'll be included but with an additional test that dlerror() returns
> non-NULL. That should make the same code work on both platforms.
>
More information about the BRLTTY
mailing list