[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: DynaLoader/MakeMaker problem? - Apache::ASP: crash when placed in startup.pl
Daniel Jacobowitz wrote:
> This part confuses me. From my dlopen() manpage:
>
> dlclose decrements the reference count on the dynamic
> library handle handle. If the reference count drops to
> zero and no other loaded libraries use symbols in it, then
> the dynamic library is unloaded. If the dynamic library
>
> But the dynamic linker clearly shows other libraries using symbols in
> mod_perl.so. Perhaps it means 'has it marked as SO_NEEDED' instead of
> merely 'using symbols in it'.
It's nothing like that simple for Solaris I'm afraid. Also, cyclic
dependencies muddy the waters even further. I'm going to try to build a
simple test case for this week and submit it to our linker folks to see
what they think.
> > I think it is somewhat of an edge case - you could argue that even
> > though there is no explicit dependency between the perl XS .so files and
> > the perl libperl.so, the linker should be able to notice that it has
> > used symbols from libperl.so and increment the refcounts accordingly.
> > Then again, you could also argue that there should be an explicit
> > dependency between the perl XS .so files and the perl libperl.so.
>
> Certainly not.
>
> For my different perspective on this, bear in mind I work on Linux. We
> have a static libperl.a available for embedded applications, and perl
> does not use a shared library.
>
> Thus, there can not be a dependency between the modules and the perl
> binary, because it is a binary and not a soname; and obviously you do
> not want them linked to libperl.a to get symbols from it, as you end up
> with private copies of things. They need to be unresolved and without
> a dependency.
Agreed - in the case of a libperl.a it is not relevant to add a
dependency - in fact it is impossible as libperl is pulled into the
executable at build time rather than run time, so the idea of a
dependency between an XS module and libperl.a is nonsensical. I'm
specifically talking about libperl.so.
> > a) Requesting that MakeMaker adds a dependency between the .so files it
> > generates and the perl libperl.so
> >
> > b) Requesting that a 'remove a module' method is added to DynaLoader
>
> As said, I need to go for (b).
Yes, but if you *were* using a libperl.so than adding the dependency
would also make sense.
> > It worked for me as well. One slight concern is that in the attached
> > "after" file it appears that DynaLoaded .so files are unloaded twice in
> > succession - I'll try tracking down exactly why this is.
>
> Doesn't happen here. I played with ltrace and logged the dl*() calls:
>
> dlopen("/usr/lib/apache/1.3/mod_cgi.so", 258) = 0x080a4fd8
> dlopen("/usr/lib/apache/1.3/mod_mime.so", 258) = 0x080a5358
> dlopen("././mod_perl.so", 258) = 0x080a5680
> dlopen("/usr/lib/apache/1.3/mod_userdir."..., 258) = 0x080a5a88
> dlopen("/usr/lib/perl5/5.005/i386-linux/"..., 1) = 0x0811cac8
> dlclose(0x080a5a88) = 0
> dlclose(0x080a5680) = 0
> dlclose(0x080a5358) = 0
> dlclose(0x080a4fd8) = 0
> dlopen("/usr/lib/apache/1.3/mod_cgi.so", 258) = 0x081819a0
> dlopen("/usr/lib/apache/1.3/mod_mime.so", 258) = 0x08181bd0
> dlopen("././mod_perl.so", 258) = 0x080a4fb0
> dlopen("/usr/lib/apache/1.3/mod_userdir."..., 258) = 0x080b20f8
> dlopen("/usr/lib/perl5/5.005/i386-linux/"..., 1) = 0x081f7b20
> dlopen("/usr/lib/perl5/5.005/i386-linux/"..., 1) = 0x08271320
I'm not talking about dlclose calls, I'm talking about unloads of the
.so files - the two are not the same thing. Unloading a single .so file
via dlclose can trigger the unloading of several others if they have
been pulled in by ld.so via a linker dependency. To illustrate this I
have a new trace with both the dlopen/dlclose calls AND the subsequent
unloads shown. As you can see, a single dlopen may result in the
loading of several .so files, and a dlclose can trigger the unloading of
several .so files - see the attachment.
> I'm still seeing the problem that perl is not properly destroying
> itself, or destroying some sort of symbol from modules; thus every time
> I SIGHUP apache, its heap grows by an amount proportional to the number
> of loaded modules. I haven't figured out what isn't getting recovered
> yet; I'll keep beating on that.
I'll take a peek myself.
Whatever, your patch still results in a mod_perl that doesn't SEGV when
built with APXS.
That's got to be a major step forwards.
Thanks,
Alan Burlison
Linker audit trace with unload patch applied
============================================
LOAD: MAP=base ADDR=0x10000 FILE=./httpd
LOAD: MAP=ld.so ADDR=0xff3b0000 FILE=/usr/lib/ld.so.1
LOAD: MAP=base ADDR=0xff2d0000 FILE=/home1/rootal/spoof/libdlfcn.so
LOAD: MAP=base ADDR=0xff1e0000 FILE=/usr/lib/libsocket.so.1
LOAD: MAP=base ADDR=0xff100000 FILE=/usr/lib/libnsl.so.1
LOAD: MAP=base ADDR=0xff320000 FILE=/usr/lib/libdl.so.1
LOAD: MAP=base ADDR=0xff000000 FILE=/usr/lib/libc.so.1
LOAD: MAP=base ADDR=0xff0e0000 FILE=/usr/lib/libmp.so.2
LOAD: MAP=base ADDR=0xff1b0000 FILE=/usr/platform/SUNW,Ultra-1/lib/libc_psr.so.1
dlopen: /home2/web/apache_1.3.9/libexec/libperl.so
LOAD: MAP=base ADDR=0xfef80000 FILE=/home2/web/apache_1.3.9/libexec/libperl.so
LOAD: MAP=base ADDR=0xfee00000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/CORE/libperl.so
LOAD: MAP=base ADDR=0xfede0000 FILE=/usr/lib/libcrypt_i.so.1
LOAD: MAP=base ADDR=0xfedc0000 FILE=/usr/lib/libgen.so.1
dlopen: /home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/Data/Dumper/Dumper.so
LOAD: MAP=base ADDR=0xfeda0000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/Data/Dumper/Dumper.so
dlopen: /home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/B/B.so
LOAD: MAP=base ADDR=0xfed60000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/B/B.so
dlclose: /home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/Data/Dumper/Dumper.so
UNLOAD: MAP=base ADDR=0xfeda0000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/Data/Dumper/Dumper.so
UNLOAD: MAP=base ADDR=0xfeda0000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/Data/Dumper/Dumper.so
dlclose: /home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/B/B.so
UNLOAD: MAP=base ADDR=0xfed60000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/B/B.so
UNLOAD: MAP=base ADDR=0xfed60000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/B/B.so
dlclose: /home2/web/apache_1.3.9/libexec/libperl.so
UNLOAD: MAP=base ADDR=0xfee00000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/CORE/libperl.so
UNLOAD: MAP=base ADDR=0xfef80000 FILE=/home2/web/apache_1.3.9/libexec/libperl.so
UNLOAD: MAP=base ADDR=0xfede0000 FILE=/usr/lib/libcrypt_i.so.1
UNLOAD: MAP=base ADDR=0xfedc0000 FILE=/usr/lib/libgen.so.1
UNLOAD: MAP=base ADDR=0xfef80000 FILE=/home2/web/apache_1.3.9/libexec/libperl.so
UNLOAD: MAP=base ADDR=0xfee00000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/CORE/libperl.so
UNLOAD: MAP=base ADDR=0xfede0000 FILE=/usr/lib/libcrypt_i.so.1
UNLOAD: MAP=base ADDR=0xfedc0000 FILE=/usr/lib/libgen.so.1
dlopen: /home2/web/apache_1.3.9/libexec/libperl.so
LOAD: MAP=base ADDR=0xfef80000 FILE=/home2/web/apache_1.3.9/libexec/libperl.so
LOAD: MAP=base ADDR=0xfee00000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/CORE/libperl.so
LOAD: MAP=base ADDR=0xfede0000 FILE=/usr/lib/libcrypt_i.so.1
LOAD: MAP=base ADDR=0xfedc0000 FILE=/usr/lib/libgen.so.1
dlopen: /home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/Data/Dumper/Dumper.so
LOAD: MAP=base ADDR=0xfeda0000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/Data/Dumper/Dumper.so
dlopen: /home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/B/B.so
LOAD: MAP=base ADDR=0xfed60000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/B/B.so
dlopen: nss_files.so.1
LOAD: MAP=base ADDR=0xfed30000 FILE=/usr/lib/nss_files.so.1
^C
UNLOAD: MAP=base ADDR=0xfeda0000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/Data/Dumper/Dumper.so
UNLOAD: MAP=base ADDR=0xfed60000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/auto/B/B.so
UNLOAD: MAP=base ADDR=0xfee00000 FILE=/home1/software/perl/debug/lib/5.00503/sun4-solaris/CORE/libperl.so
UNLOAD: MAP=base ADDR=0xfef80000 FILE=/home2/web/apache_1.3.9/libexec/libperl.so
UNLOAD: MAP=base ADDR=0xff1e0000 FILE=/usr/lib/libsocket.so.1
UNLOAD: MAP=base ADDR=0xfed30000 FILE=/usr/lib/nss_files.so.1
UNLOAD: MAP=base ADDR=0xff100000 FILE=/usr/lib/libnsl.so.1
UNLOAD: MAP=base ADDR=0xff0e0000 FILE=/usr/lib/libmp.so.2
UNLOAD: MAP=base ADDR=0xfede0000 FILE=/usr/lib/libcrypt_i.so.1
UNLOAD: MAP=base ADDR=0xfedc0000 FILE=/usr/lib/libgen.so.1
UNLOAD: MAP=base ADDR=0xff2d0000 FILE=/home1/rootal/spoof/libdlfcn.so
UNLOAD: MAP=base ADDR=0xff000000 FILE=/usr/lib/libc.so.1
- References to:
-
Alan Burlison <Alan.Burlison@uk.sun.com>
Daniel Jacobowitz <drow@false.org>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]