I have isolated a case where perl is happy but D::C segfaults

++++++++++++++++
sort.pl
++++++++++++++++
#!/usr/bin/perl -w

use strict;

my %sort = (B => \&backwards,
       F => \&forwards);

sub backwards {
   return $b cmp $a;
}

sub forwards {
   return $a cmp $b;
}

sub GetAlgorithm {
   my ($alg) = @_;

   return $sort{$alg};
}

my @list = qw( a d e c g );

my $alg = GetAlgorithm(('B', 'F')[int(rand(2))]);

@list = sort {&{$alg}} @list;

use Data::Dumper;

print STDERR Dumper([EMAIL PROTECTED]);

++++++++++++++

[EMAIL PROTECTED] perl]$ perl -MDevel::Cover sort.pl
Devel::Cover 0.52: Collecting coverage data for branch, condition, statement, subroutine and time.
Pod coverage is unvailable. Please install Pod::Coverage from CPAN.
Selecting packages matching:
Ignoring packages matching:
/Devel/Cover[./]
^t/
\.t$
^test\.pl$
Ignoring packages in:
.
/usr/lib/perl5/5.8.0
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
Segmentation fault


[EMAIL PROTECTED] perl]$ perl sort.pl
$VAR1 = [
         'g',
         'e',
         'd',
         'c',
         'a'
       ];

+++++++++++

I've also tried the sub reference as { $alg->() }, but to no avail.

Any pointers as to how I can progress solving this ? Do you need the core dump ?

++++++++++++
Platform info
[EMAIL PROTECTED] perl]$ uname -a
Linux itdevtst 2.4.20-31.9 #1 Tue Apr 13 18:04:23 EDT 2004 i686 i686 i386 GNU/Linux
[EMAIL PROTECTED] perl]$ perl -v


This is perl, v5.8.0 built for i386-linux-thread-multi
(with 1 registered patch, see perl -V for more detail)


-- Leif Eriksen Snr Developer http://www.hpa.com.au/ phone: +61 3 9217 5545 email: [EMAIL PROTECTED]

Reply via email to