Hi,
Am Mittwoch, 15. November 2006 18:17 schrieb Bastian Friedrich:
> In a nutshell: With RTLD_LOCAL (default behavior on linux), perl segfaults.
> With RTLD_GLOBAL, t_relay segfaults :((
I've dug deeper into the topic:
* Yes, a shared library that is dlopen'ed and linked against perl needs
RTLD_GLOBAL. See
http://groups.google.com/group/comp.lang.perl.misc/msg/a2877cf7e0c656fe
* If all modules but sl.so are loaded with RTLD_GLOBAL, everything is fine
* If sl.so is loaded with RTLD_GLOBAL, a segfault occurs in tm.so's code
(huh???). At least, my gdb says so ;)
I was (yet) unable to find the reason for the segfault. Thus, I'd like to
propose some options:
* Introduce a flag that lets the user configure whether RTLD_GLOBAL should be
set. See attached patch: If the user configures
'loadmodule "/my/module.so"', everything stays at it is. By appending a "G",
RTLD_GLOBAL is configured: 'loadmodule "/my/module.so G"'
* Set RTLD_GLOBAL, and fix the segfault... I expect some symbol collision, but
was unable to locate it :(
* Add an optional parameter to load_module(), plus a
| LOADMODULE STRING COMMA NUMBER
path in the config parser. You'd 'loadmodule "/my/module.so", 1' then.
* Best, but a little more difficult: open module regularly. Try to call a
function "getflags()" or something similar in that module. If it exists,
close library again and re-open it with the new flags.
Looking forward to read about your opinions!
Thx,
Bastian
--
Collax GmbH . Burkheimer Straße 3 . 79111 Freiburg . Germany
p: +49 (0) 761-45684-24
f: +49 (0) 761-45684-10 www.collax.com
\ "In most countries selling harmful things like drugs is punishable.
\ Then howcome people can sell Microsoft software and go unpunished?"
\ Hasse Skrifvars
--- sr_module.c.ori 2006-11-22 14:19:17.000000000 +0100
+++ sr_module.c 2006-11-24 09:36:08.000000000 +0100
@@ -199,12 +199,30 @@
char* error;
struct module_exports* exp;
struct sr_module* t;
+ int flags;
+ int pathlen;
#ifndef RTLD_NOW
/* for openbsd */
#define RTLD_NOW DL_LAZY
#endif
- handle=dlopen(path, RTLD_NOW); /* resolve all symbols now */
+
+ flags = RTLD_NOW; /* resolve all symbols now */
+
+#ifdef RTLD_GLOBAL
+/* May be unavailable on some systems, thus ifdef'd */
+
+ pathlen = strlen(path);
+ if (pathlen > 2) {
+ if ((path[pathlen-2] == ' ') && (path[pathlen-1] == 'G')) {
+ flags |= RTLD_GLOBAL;
+ path[pathlen-2] = 0; path[pathlen-1] = 0;
+ }
+ }
+#endif
+
+ handle=dlopen(path, flags);
+
if (handle==0){
LOG(L_ERR, "ERROR: load_module: could not open module <%s>: %s\n",
path, dlerror() );
_______________________________________________
Devel mailing list
[email protected]
http://openser.org/cgi-bin/mailman/listinfo/devel