Further to my last post a more in depth investigation has proven the
problem lies in the Clone module.
I hope this Helps
Paddy
----- Forwarded message from Nicholas Clark <nick#unfortu.net> -----
Envelope-to: chris#nodnol.org
Delivery-date: Wed, 19 Mar 2003 21:39:38 +0000
Date: Wed, 19 Mar 2003 21:36:24 +0000
To: chris#nodnol.org
Subject: Re: Perl segfaulting bug
From: Nicholas Clark <nick#unfortu.net>
On Wed, Mar 19, 2003 at 03:08:52PM +0000, chris#nodnol.org wrote:
Show quoted text>
> Nick,
>
> MBM suggested you might like to take a look at this problem we found:
> (we've added it to rt.cpan.org under Hash::Merge.)
>
> Under perl 5.6.1 and perl 5.8.0 on debian 3.0r1 and redhat 8.0
> respectively, and also on Solaris 8 and 5.6.1, the following code
> segfaults Perl:
>
> perl -MHash::Merge=merge -le '%a=(a=>undef);%b=(c=>1);$c=merge(\%a,\%b)'
>
> but
>
> perl -MHash::Merge=merge -le
'%a=(a=>undef);%b=(c=>1);$c=merge(\%a,\%b); undef $c'
Show quoted text>
> does not.
>
> More worryingly:
>
> perl -MHash::Merge=merge -le '%a=(a=>undef);$c=merge(\%a)'
> perl -MHash::Merge=merge -le '@a=(undef);$c=merge(\@a)'
> perl -MHash::Merge=merge -le '$a={};$c=merge($a)'
> also segfault...
So does
perl -e 'use Clone qw(clone); $a = \$b; undef $a; $c = clone $a;'
It's a bug in Clone:
$ perl -e 'use Clone qw(clone); $a = \$b; undef $a; $c = clone $a; use
Devel::Peek; Dump $c'
SV = RV(0x813a864) at 0x812e2ac
REFCNT = 1
FLAGS = (ROK)
RV = 0x0
SV = 0
ROK shouldn't be set when RV doesn't point to a reference. (Clearly here
it's
a NULL pointer)
The error seems to be in this bit of code in Clone.xs
case SVt_RV: /* 3 */
TRACEME(("ref scalar\n"));
clone = NEWSV(1002, 0);
sv_upgrade(clone, SVt_RV);
SvROK_on(clone);
break;
I'm not quite sure what it ought to be doing - I think a straight
clone = newSVsv (ref);
ought to work, but that causes it to fail its tests.
I'm not convinced I like Clone in preference to Storable's dclone, given
that
Storable is now in core and some effort has been put into trying to keep it
up-to-date on subtleties of the internal representations of things, such as
Unicode in hash keys:
$ perl5.8.0-32-g -MClone=clone -le '%a=(chr 256 =>1);$c=clone \%a;
print ord foreach keys %$c'
196
$ perl5.8.0-32-g -MStorable=dclone -le '%a=(chr 256 =>1);$c=dclone \%a;
print ord foreach keys %$c'
256
I'm biased, as I fixed Storable for Unicode hash keys before 5.8.0 was
released.
Also OK, it isn't strictly fair complaining that clone can't do this, as
5.7.something did extend the hash API to cope with Unicode in hash keys.
Hash::Merge is innocent. Free the Hash::Merge 1 :-)
Nicholas Clark
Show quoted text----- End forwarded message -----