Re: Allow RTLD_GLOBAL to be optional



On 21 Apr 2001, Martin Baulig wrote:

> Hi guys,
> 
> can you please add G_MODULE_BIND_PRIVATE or something like
> this to GModuleFlags which will tell gmodule not to use
> RTLD_GLOBAL ?

	Yes, I agree completely.

	I'm not sure about your specific issue -- there's a testgmodule
program that checks this sort of thing, and it seems to work.  (why it
works, I don't know -- what you state below is correct...)

	But in general, it would make life much simpler to be able to NOT
use global symbols.  One thing I did with C++ modules in the past was to
have a special symbol name (e.g., "plugin") which was a class of the
appropriate type.  Worked fine every time.  Using GModule, such programs
crash (usually segfault) every time.  After digging, I discovered that it
was because the two symbols (in two /separate/ modules) were interfering
with eachother.

	I know it crashes because I originally wrote GModule-- this way.  I
had to put in a very screwed-up (and probably unportable) hack to get it to
work.

	I've been meaning to bring it up for some time, but I keep spacing
it off due to work.  Alas, a lot of my open-source stuff is suffering
because of my lack of time these days. :-/

	At any rate, back to gmodule: one reason people use modules is to
avoid namespace collisions (take a look at the XAnim home page ;-).  When I
write a series of functions for /my/ plugin, I'd prefer not to have to worry
about whether the function names collide with those from other vendors. 
Also, as a program writer, I would like to allow miscellaneous
vendors/people to create plugins for my program(s) without having to talk to
each other about what namespaces to use.

	The question, of course, is how to fix this.  In Windows (as near as
I can tell from the gmodule source) one can apparently specify specific
symbols to make global.  In UNIX, with libdl, it appears to be all or
nothing.  99% of the time, I prefer 'nothing', but theoretically there could
be situations where I'd want to be able to access symbols in other modules. 
I like the special flag you noted above, because (a) it's portable, and (b)
anyone using it knows not to expect module symbols to be globally available. 

	Yays, nays from anyone else?  Does anyone have any pressing reasons
why gmodule should continue to mangle the namespace?

- Bibek



> Yes, I really want to use g_module_symbol() for each symbol of
> my shared library and yes, I really do not want to export its
> symbols.
> 
> If you still don't see why this is necessary and why someone
> may want such a "strange" feature, lemme explain:
> 
> I have several shared libraries, each of them containing some
> global symbol, let's call it `foo'. If I don't give dlopen() the
> RTLD_GLOBAL flag, I can load them all into my application and then
> use dlsym() to get `foo'.
> 
> When I use gmodule and not dlopen/dlsym directly, this always
> crashes - imagine the following situation:
> 
> Library A:
> 
> ====
> void
> bar (void)
> {
>    g_message (G_STRLOC " - Library A");
> }
> 
> void
> foo (void)
> {
>    g_message (G_STRLOC " - Library A");
> 
>    bar ();
> }
> ===
> 
> Library B:
> 
> ====
> void
> bar (void)
> {
>    g_message (G_STRLOC " - Library B");
> }
> 
> void
> foo (void)
> {
>    g_message (G_STRLOC " - Library B");
> 
>    bar ();
> }
> ===
> 
> If I use dlopen without RTLD_GLOBAL, loading both A and B into my application
> and then calling both foo's via dlsym() works just fine.
> 
> With gmodule, B's foo() calls A's bar().
> 
> -- 
> Martin Baulig
> martin gnome org (private)
> baulig suse de (work)
> 
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
> 





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