develooper Front page | perl.perl5.porters | Postings from January 2008

RE: Double free error in 5.10.0

Thread Previous | Thread Next
From:
Paul Marquess
Date:
January 5, 2008 07:41
Subject:
RE: Double free error in 5.10.0
Message ID:
013601c84fb1$3f47b990$6601a8c0@myopwv.com
From: H.Merijn Brand [mailto:h.m.brand@xs4all.nl]
 
> On Fri, 21 Dec 2007 09:30:24 +0100, "H.Merijn Brand" <h.m.brand@xs4all.nl>
> wrote:
> 
> > Once I get a hint about what/where causes this failure, I could try to
> > create a smaller test case from this 8000+ lines script that works fine
> > in 5.8.8-dor, but does not in 5.10.0. Both 64bitint on Linux
> 
> Here's the narrowed down test case that reproducably barfs:
> 
> --8<---
> #!/pro/bin/perl
> 
> use strict;
> use warnings;
> 
> use DB_File;
> 
> my %db;
> 
> tie %{$db{lastc}}, "DB_File", "db_test.db", O_CREAT|O_RDWR, 0666,
> $DB_HASH;
> 
> $db{lastc}{BR41967} = "December 20, 2007";
> 
> my %month = (qw(January 1 February 2 March 3 April 4 May 5 June 6 July 7
> 		August 8 September 9 October 10 November 11 December 12));
> 
> $db{lastc}{BR41967} =~ s{(\S+) (\d+),\s*(\d+)}
> 			{sprintf "%04d%02d%02d", $3, $month{$1}, $2}e;
> 
> untie %{$db{lastc}};
> -->8---
> 
> This is the cut-down version from the real life example. I'm sure it can
> be
> shorter

Just spotted this & can reproduce on a 32-bit Linux. 

I tried SDBM_File to see if it was a DB_File specific error - it spat out
the double free as well.

So the next thing was to use Tie::StdHash & remove all XS code from the
equation. It also failed with the double free error.

Interestingly 5.8.x @ 32328 didn't produce the double free - it cored.

Script below.

Paul


use strict;
use warnings;

use Tie::Hash;

{
  package ReportHash;
  our @ISA = 'Tie::StdHash';

  sub TIEHASH  {
    my $storage = bless {}, shift;
    $storage
  }

  sub STORE    {
    warn "Storing data '$_[2]' with key $_[1]\n";
    $_[0]{$_[1]} = $_[2]
  }

  sub FETCH    {
    my $got = $_[0]{$_[1]} ;
    warn "Fetching data '$got' with key $_[1].\n";
    $got;
  }

}

my %db;

tie %{$db{lastc}}, "ReportHash";

$db{lastc}{BR41967} = "December 20, 2007";

my %month = (qw(January 1 February 2 March 3 April 4 May 5 June 6 July 7
		August 8 September 9 October 10 November 11 December 12));

$db{lastc}{BR41967} =~ s{(\S+) (\d+),\s*(\d+)}
			{sprintf "%04d%02d%02d", $3, $month{$1}, $2}e;

untie %{$db{lastc}};


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About