perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <joe+gm...@sunstarsys.com>
Subject Re: t/TEST t/directive/cmdparms.t segfaults w/5.8.5+ithreads
Date Sat, 02 Oct 2004 04:14:36 GMT
Stas Bekman <stas@stason.org> writes:

> Geoffrey Young wrote:
> > Joe Schaefer wrote:
> >
> >>Joe Schaefer <joe+gmane@sunstarsys.com> writes:
> >>
> >>
> >>
> >>>1. Problem Description:
> >>>
> >>>Current cvs segfaults w/perl 5.8.5, not reproducible with 5.8.4:
> >>>
> >>>#0  0x0000002a9682334b in Perl_safesysmalloc (size=24) at util.c:78
> >>>78              my_exit(1);
> >>>
> >>>This may be an ithread-related bug in 5.8.5, not mp2.
> >>>
> >>>% t/TEST -v t/directive/cmdparms.t
> >>
> >>
> >>Any assembler gurus out there?  This is starting to look
> >>like a gcc/ld bug on my debian-amd64 box now...
> > fwiw, I don't see this error on my 5.8.5 threaded perl (-V below), but I'm
> > not using the same system (or processor) you are.  I don't know if anything
> > else stands out...
> 
> Same here, i686 and no segfault.
> 
> What the assembly dump is helpful for? do you think the C function wasn't
> compiled properly? 

gdb was acting very weird, and I was losing confidence in what
I was seeing, but Joe cleared up the fog for me.  Here's what
happens on the bad request, letting it segfault this time (I recompiled
perl-5.8.5 w/ -Doptimize="-gdwarf-2 -g3" to enable macro expansions
in gdb):

0x0000002a967c486d in Perl_safesysmalloc (size=24) at util.c:75
(gdb) list Perl_safesysmalloc
54	
55	/* paranoid version of system's malloc() */
56	
57	Malloc_t
58	Perl_safesysmalloc(MEM_SIZE size)
59	{
60	    dTHX;
61	    Malloc_t ptr;
62	#ifdef HAS_64K_LIMIT
63		if (size > 0xffff) {
(gdb) macro expand dTHX
expands to:  PerlInterpreter *my_perl __attribute__((unused)) = ((PerlInterpreter *)pthread_getspecific(PL_thr_key))
(gdb) p PL_thr_key
$1 = 3
(gdb) p my_perl
$2 = (PerlInterpreter *) 0x0


So it seems Perl_safesysmalloc depends on PERL_SET_CONTEXT.  This
patch fixes the segfault, but I'm not sure it's an acceptable solution:

Index: src/modules/perl/modperl_module.c
===================================================================
RCS file: /home/cvspublic/modperl-2.0/src/modules/perl/modperl_module.c,v
retrieving revision 1.17
diff -u -r1.17 modperl_module.c
--- src/modules/perl/modperl_module.c   4 Mar 2004 06:01:07 -0000       1.17
+++ src/modules/perl/modperl_module.c   2 Oct 2004 04:06:04 -0000
@@ -185,6 +185,7 @@
 #ifdef USE_ITHREADS
     interp = modperl_interp_pool_select(p, s);
     aTHX = interp->perl;
+    PERL_SET_CONTEXT(aTHX);
 #endif

     table = modperl_module_config_table_get(aTHX_ TRUE);


-- 
Joe Schaefer


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message