We have yet another chicken-n-egg problem with perl_clone. If you do a simple:
use threads;
my $thread = threads->create(sub {}, undef)and STDOUT is opened to some PerlIO layer, an attempt to clone it will be performed. The problem is that this cloning happens too early:
perl-5.8.6/sv.c:10859:
#ifdef PERLIO_LAYERS
/* Clone PerlIO tables as soon as we can handle general xx_dup() */
PerlIO_clone(aTHX_ proto_perl, param);
#endifxx_dup() works for the core perl, but it doesn't take into account that a custom PerlIO layer may need other bits set in my_perl. In the above case I get a segfault because PL_defstash is bogus. it's set only after PerlIO_clone is called. (line 10954) I get this segfault:
#0 0x404c8a04 in Perl_gv_fetchpv (my_perl=0x85e6540,
nambeg=0x404939d0 "Apache::RequestRec", add=1, sv_type=11) at gv.c:670
#1 0x40479f37 in PerlIOApache_getarg (my_perl=0x85e6540, f=0x828634c,
param=0xbfffe9c0, flags=1) at modperl_io_apache.c:87
#2 0x405c55b5 in PerlIOBase_dup (my_perl=0x85e6540, f=0x83576c4, o=0x828634c,
param=0xbfffe9c0, flags=1) at perlio.c:2187
#3 0x405c1e50 in PerlIO_fdupopen (my_perl=0x85e6540, f=0x828634c,
param=0xbfffe9c0, flags=1) at perlio.c:542
#4 0x40555faf in Perl_fp_dup (my_perl=0x85e6540, fp=0x828634c, type=0 '\0',
param=0xbfffe9c0) at sv.c:9505
#5 0x405c22a5 in PerlIO_clone (my_perl=0x85e6540, proto=0x8abfb10,
param=0xbfffe9c0) at perlio.c:650
#6 0x4055a6fe in perl_clone (proto_perl=0x8abfb10, flags=2) at sv.c:10859
#7 0x4078aa50 in Perl_ithread_create (my_perl=0x8abfb10, obj=0x0,
classname=0x82dc948 "threads", init_function=0x8153728, params=0x815377c)
at threads.xs:426
#8 0x4078b3f7 in XS_threads_new (my_perl=0x8abfb10, cv=0x82f0698)
at threads.xs:687the segfault happens here:
if (!stash)
stash = PL_defstash;
if (!stash || !SvREFCNT(stash)) /* symbol table under destruction */PL_defstash == 0xabababab here
PerlIOApache_getarg happens to call gv_fetchpv which needs a valid PL_defstash.
How do we resolve this problem?
This is not the first time we hit a segfault, due to PerlIO+clone. Some of those are still unresolved (e.g. perl -m still segfaults under threads)
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
