[racket-dev] Strange error with gui and ffi

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Jan 20 12:28:09 EST 2012

At Thu, 19 Jan 2012 15:40:07 +0100, Tobias Hammer wrote:
>  > Even if libVLCore is statically linked to a libjpeg, I think it could
>  > interact with dynamic loading of another libjpeg, depending on the
>  > platform and linking options.
> 
> I digged a bit more and found the following line the rackets libffi:
> handle = dlopen(name, RTLD_NOW | RTLD_GLOBAL);
> If i interpret the manpages correct that means that all symbols from the 
> lib are loaded and used to resolve references. That may be convenient 
> for the libraries that the racket core uses but may lead strange 
> behavior like the one i got whenever name clashes happen.
> 
> Maybe it would be a good idea to make this import all behavior optional.

I agree that RTLD_GLOBAL should be removed by default,
but it should be made available as an option. Meanwhile, the details of
`(ffi-lib #f)' will have to change for backward compatibility.


As far as I can tell or remember, RTLD_GLOBAL is mostly there to make
`(ffi-lib #f)' work, where the handle produced by `(ffi-lib #f)' finds
an export in any previously loaded library.

Since Racket keeps a table of all loaded libraries, maybe the right
change is to implement `(ffi-lib #f)' by traversing the table in
addition to using a global lookup, which means that `(ffi-lib #f)' can
work without always loading libraries with RTLD_GLOBAL. Meanwhile,
RTLD_GLOBAL could be optional behavior, as you suggest.


Posted on the dev mailing list.