Subject: | Clone segfault (isolated example) |
Date: | Mon, 2 Oct 2006 18:31:32 -0400 |
To: | bug-Clone [...] rt.cpan.org |
From: | rabbit [...] rabbit.us (Peter Rabbitson) |
I stumbled upon a segfault in Clone. It took me a while to strip down my
code (a 30k lines monster) to the attached example. However I had to use
a Storable snapshot from the big application - if I just create a
variable within the simple script with the same contents 1:1 - the
segfault does not happen. On the other hand the data in
offender.storable is real and valid. Also if I do not execute the
sprintf - the segfault does not occur either. It has to be some very
peculiar combination of wrong stuff at the wrong place. Unfortunately my
C knowledge is beyond minimal so I can just submit the bug report. As a
side note - the same segfault happens in the big application by
obtaining the data from XML::Twig, so I wouldn't blame Storable.
Regards
Peter
Complete sample with code and data:
http://rabbit.us/pool/clone_problem.tar.gz
Code part:
#!/usr/bin/perl
use warnings;
use strict;
use Clone qw/clone/;
use Storable qw/retrieve/;
my $order = retrieve ('offender.storable');
foreach my $item (@{$order->{items}}) {
$item->{sku} = sprintf ('<<bg_color=%s>>%s<</bg_color>>%s',
'#EA0',
substr ($item->{sku}, 0, 4),
substr ($item->{sku}, 4),
);
}
my $cloned = clone ($order);
1;