New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DynaLoader doesn't dlclose XS code on interpreter exit #1046
Comments
From root@mongo.uk.sun.comDynaLoader assumes that exiting of the perl interpreter is the same thing as The failure of DynaLoader to dlclose the XS modules leads to a very insiduous DynaLoader maintains a list of opened .so files in dl_librefs - on exit it Perl Info
|
From [Unknown Contact. See original ticket]Super-User writes:
Looks like "do not do this" category. Though may be it is safe to
Is not this list dead at the end of global destruction? 1/2 ;-) Ilya |
From @AlanBurlisonIlya Zakharevich wrote:
Right. Tell that to the Apache developers.
Couldn't it be done in an END block inside DynaLoader? Alan Burlison |
From @AlanBurlisonAlan Burlison wrote:
I've a patch to do this for 5.005_63 (attatched) for at least those Unfortunately I can't actually get mod_perl + a load of other stuff to Could a DynaLoader guru have a quick look at the patch and let me know I have backported the patch to 5.005_03, and it appears that mod_perl Sigh. What a mess. Alan Burlison |
From @AlanBurlisonDynaLoader.patch*** ext/DynaLoader/DynaLoader_pm.PL.orig Wed Jan 19 13:27:35 2000
--- ext/DynaLoader/DynaLoader_pm.PL Wed Jan 19 16:02:57 2000
***************
*** 251,256 ****
--- 251,264 ----
#}
+ sub END {
+ return if (! defined(&dl_unload_file));
+ while (my $libref = pop(@dl_librefs)) {
+ dl_unload_file($libref);
+ }
+ }
+
+
# Let autosplit and the autoloader deal with these functions:
__END__
***************
*** 466,471 ****
--- 474,480 ----
@symbols = dl_undef_symbols() C
dl_install_xsub($name, $symref [, $filename]) C
$message = dl_error C
+ dl_unload_file($libref) C
=over 4
***************
*** 709,714 ****
--- 718,735 ----
$filename is not defined then "DynaLoader" will be used.
+ =item dl_unload_file()
+
+ Syntax:
+
+ dl_unload_file($libref)
+
+ Unloads the library referred to by $libref. Not normally called explicitly,
+ but by an END block in DynaLoader.pm that unloads all the modules whos handles
+ are stored in @dl_librefs. This function may be absent on platforms that don't
+ require this functionality.
+
+
=item bootstrap()
Syntax:
*** ext/DynaLoader/XSLoader_pm.PL.orig Wed Jan 19 13:56:48 2000
--- ext/DynaLoader/XSLoader_pm.PL Wed Jan 19 15:48:54 2000
***************
*** 126,131 ****
--- 126,140 ----
goto &DynaLoader::bootstrap_inherit;
}
+
+ sub END {
+ package DynaLoader;
+ return if (! defined(&dl_unload_file));
+ while (my $libref = pop(@dl_librefs)) {
+ dl_unload_file($libref);
+ }
+ }
+
__END__
=head1 NAME
*** ext/DynaLoader/dl_dlopen.xs.orig Wed Jan 19 13:27:47 2000
--- ext/DynaLoader/dl_dlopen.xs Wed Jan 19 13:33:38 2000
***************
*** 169,174 ****
--- 169,185 ----
sv_setiv( ST(0), PTR2IV(RETVAL));
+ int
+ dl_unload_file(libhandle)
+ void * libhandle
+ CODE:
+ DLDEBUG(2, PerlIO_printf(Perl_debug_log, "dl_unload_file(handle=%lx)\n",
+ (unsigned long) libhandle));
+ RETVAL = dlclose(libhandle);
+ if (RETVAL != 0)
+ SaveError(aTHX_ "%s",dlerror()) ;
+
+
void *
dl_find_symbol(libhandle, symbolname)
void * libhandle
|
From [Unknown Contact. See original ticket]Alan Burlison writes:
Too early. The only safe place (if any) should be Ilya |
From @timbunceOn Wed, Jan 19, 2000 at 02:38:18PM -0500, Ilya Zakharevich wrote:
Good point, but I'm not so sure. Objects have been cleaned, via If destruct_level==0 then that's just about the last thing If destruct_level > 0 then there's lots of SvREFCNT_dec'ing going on Also the dlclose's should be skipped unless perl_destruct_level > 0. Other random observation, I see that the PERL_DESTRUCT_LEVEL env var Tim. |
From [Unknown Contact. See original ticket]On Thu, Jan 20, 2000 at 11:16:00AM +0000, Tim Bunce wrote:
Do not think so: perl -wle 'sub a::new {bless [],"a"}; my $a="a"->new;END{print "<$a>"}'
destruct_level==0 has nothing to do with embedding anyway... Ilya |
From @timbunceOn Thu, Jan 20, 2000 at 01:14:42PM -0500, Ilya Zakharevich wrote:
Ah, I see I confused PL_exitlist with PL_endav. Looks like DynaLoader::bootstrap just needs to call perl_atexit(...)
I didn't say it did (though I'd disagree with "nothing to do"). Tim. |
From [Unknown Contact. See original ticket]On Thu, Jan 20, 2000 at 11:18:42PM +0000, Tim Bunce wrote:
In which case, I propose this: mod_perl can save a copy of It's a bit of a messy hack, but how's that sound for coping with Dan /--------------------------------\ /--------------------------------\ |
From @timbunceOn Thu, Jan 20, 2000 at 08:40:23PM -0500, Daniel Jacobowitz wrote:
That's a presumption, but probably true on most platforms. For some Tim. |
From [Unknown Contact. See original ticket]Tim Bunce <Tim.Bunce@ig.co.uk> writes:
I don't think so. But if true that might explain why I get
-- |
From @gsarOn Sat, 22 Jan 2000 16:56:29 GMT, Nick Ing-Simmons wrote:
END blocks are called just before perl_run() returns. Global object Scheduling dlclose()s using call_atexit() ought to work. I'm going Sarathy |
From @gsarOn Wed, 26 Jan 2000 16:06:29 GMT, Alan Burlison wrote:
Some time before Feb 29 would be good. Today would be better. :-) Sarathy |
From @AlanBurlisonGurusamy Sarathy wrote:
Is anyone up for this? I'm in the US this week, so I'm not able to Thanks, Alan Burlison |
From @schwern
Looking at DynaLoader and skimming the discussion of this bug it seems |
From @smpeters
It looks as if the the following change fixed this... Change 5381 by gsar@auger on 2000/03/01 00:46:44 unload extension shared objects when exiting, implemented Affected files ... ... //depot/perl/ext/DynaLoader/DynaLoader_pm.PL#10 edit |
@smpeters - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#1997 (status was 'resolved')
Searchable as RT1997$
The text was updated successfully, but these errors were encountered: