dl_load_flags



executive summary: i'm proposing a one-line change, but the setup for
explaining why i think it's necessary and asking if there is any reason
not to change it takes several paragraphs.  the question itself is at the
bottom.

-=-=-=-

after several days of headscratching and code archeology to find out why
my XS extension which depends on Gtk2 refused to call functions in Gtk2.so
("relocation error: undefined symbol newSVgchar" at runtime), i finally
discovered the culprit.


  gtk2-perl/Gtk2/_blib_config.pm:12:#sub dl_load_flags { 0x01 }


this one line is commented out, meaning that at this line

  gtk2-perl/Gtk2/_blib_config.pm:76:
    my $libref = DynaLoader::dl_load_file($file, $module->dl_load_flags) or


the dl_load_flags method will be inherited from DynaLoader; the base class
method returns 0.


0x01 is the dynamic object loader flag which tells dl_open_file to allow
all other code access to the symbols in the newly opened shared object. 
this is critical if you want to share code, e.g., call
gtk2_perl_object_new() or newSvGObject() from another extension.  see the
man page for dlopen(), and look for RTLD_GLOBAL.


_blib_config.pm is the file that gets used instead of _config.pm when the
module is installed.  note that in _config.pm, the Inline parameters tell
the loader to use RTLD_GLOBAL for the Inline modules:

gtk2_perl/Gtk2/_config.pm:48:  GLOBAL_LOAD => 1,


the problem seems to be that when the module is loaded by Inline in the
uninstalled version, everything works great, but the installed version
looks to dl_load_flags in each module as it is loaded; this of course
doesn't exist, so the .so gets loaded without RTLD_GLOBAL.


looking through the CVS history for _blib_config.pm, the dl_load_flags
line has *always* been commented out.



i also notice that the Gnome2 bindings manage to call code in Gtk2.so even
though this flag is not set.  i haven't quite figured that one out, so i'm
obviously missing something.   [my project is in pure XS, using the Gtk2
headers for type macros; thus i am not using Gnome2's setup.]



Finally, my question:

is there any reason i should NOT uncomment line 12 of _blib_config.pm so
that the Gtk2.so is always loaded globally?







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