Erik Hofman wrote:

> Alex Romosan wrote:
> > trying to debug why i wasn't able to run flightgear on my laptop, i
> > think i found a problem with SGLookupFunction. the problem is that we
> > call dlclose() before we return the pointer to the GL function, and,
> > if i understand things correctly, this invalidates the handle and the
> > address might not be valid anymore (on my laptop i kept getting core
> > dumps).
> > 
> > anyway the fix is very simple: instead of calling dlopen() on libGL
> > and then passing the libGL handle to dlsym() one can simply invoke
> > dlsym on RTLD_DEFAULT (which is a special pseudo-handler that will
> > find the first occurrence of the desired symbol using the default
> > library search order). now i can run flightgear on both my laptop
> > (with a radeon mobility card) and on my desktop (nvidia card) and i
> > think the clouds actually look much better.
> 
> Unfortunately RTLD_DEFAULT isn't supported on all platforms (it isn't 
> supported in IRIX anyhow). I think that if what you describe is the 
> problem this really is a bug at your side. What happens is that the 
> function pointer is copied to ftpr. So dlcose() should never be able to 
> have any effects on this copy ??

I checked the manual page for dlclose on Linux and Tru64 ( ex Digital Unix )
On Linux, it seems dlclose decrement a counter and the library is unloaded
when it comes to zero. As libGL.so is already loaded by the linker, it should
stay linked, except perhaps if the static link was made with libGL.a.

OTOH, on Tru64, the man page says :
  The dlclose function deallocates the address space for the library
  corresponding to handle.  The results are undefined if any user function
  continues to call a symbol resolved in the address space of a library that
  has since been deallocated by dlclose.

So, if the library is really unloaded, the pointer access should be really 
undefined and could lead to a segfault. Anyway, is it really mandatory to 
do dlclose after getting the pointer ? It is if we do dlopen every time we 
get a pointer, but the handle could be allocated only once and stored 
for subsequent lookup.

-Fred


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to