Re: recent gmodule.c change



On Saturday, Jan 15, Tim Janik wrote:

> what is the exact intend of this?
> either you extern a function g_module_check_init() in a module,
> and then have to expect to have it called, or you don't, in which
> case the symbol will not be found.
> the only case i can imagine where check_init() will be NULL is with
> something like:          

Hello,

sorry for committing to glib without asking first ....

The problem was that on NetBSD g_module_symbol () doesn't work reliably as
it is supposed to; sometimes you get a TRUE return value even if the
symbol was not found.

Unfortunately this can't be fixed in an easy way since dlsym () just
returns NULL when the symbol cannot be found, but doesn't set errno != 0
(dlerr () doesn't seem to exist; at least it's #ifdef'ed to g_strerror
 (errno) at the top of gmodule-dl.c).

So there is no way to distinguish whether the symbol wasn't found or
whether it's NULL; in both cases g_module_symbol will return TRUE but
`check_init' is NULL.

We can't simply set an error condition in this case since this'd break
in all cases when a symbol is really NULL.

IMO it isn't a big problem to double-check whether `check_init' is NULL
before calling it, this is just one single line of code and it avoids that
every single application using gmodule dies a horrible death on NetBSD.

--
Martin Baulig - martin@home-of-linux.org - http://www.home-of-linux.org



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]