Hi Liz,
On Thu, 23 Aug 2012 20:54:13 +0200
Elizabeth Mattijsen <l...@dijkmat.nl> wrote:

> I can't help but think this may be caused by hash randomization.
> Have you tried running this with PERL_HASH_SEED=0 ?
> 
> See https://metacpan.org/module/perlrun#PERL_HASH_SEED .
> 

Here goes:

<<<<<<<<<<<<<
shlomif[XML-LibXML]:$trunk$ cat TEST.pl
# Feeding XML::LibXML with an invalid file, triggering memory leaks

use strict;
use warnings;

use Devel::Leak;

binmode STDOUT, ':encoding(UTF-8)';

check_libxml_memory();

sub check_libxml_memory {
    print "running\n";
    my $handle;
    my $leaveCount = 0;
    my $enterCount = Devel::Leak::NoteSV($handle);
    print STDERR "\nENTER: $enterCount SVs\n";
    {
        make_trouble(); # Trace how loading a bad doc affects memory
    }
    $leaveCount = Devel::Leak::CheckSV($handle);
    print STDERR "\nLEAVE: $leaveCount SVs\n";
}

sub make_trouble {
    my $x;

    $x = \$x;

    return;
}

1;
shlomif[XML-LibXML]:$trunk$ PERL_HASH_SEED=0 perl TEST.pl 
running

ENTER: 9318 SVs
new 0x13a14e8 : 

LEAVE: 9319 SVs
shlomif[XML-LibXML]:$trunk$ PERL_HASH_SEED=0 perl TEST.pl 
running

ENTER: 9318 SVs
new 0xf074e8 : 

LEAVE: 9319 SVs
shlomif[XML-LibXML]:$trunk$ which perl
/bin/perl
shlomif[XML-LibXML]:$trunk$ 
>>>>>>>>>>>>>

So it did not appear to have helped.

Regards,

        Shlomi Fish


> 
> Liz
> ============
> On Aug 23, 2012, at 7:33 PM, Shlomi Fish wrote:
> > with the included script below, Devel::Leak keeps outputting
> > different pointers each time for the leaked SVs. This makes
> > debugging harder. Can I have perl somehow allocate the same
> > pointers each time when an allocation is being requested? I don't
> > mind rebuilding a dedicated perl for that using perlbrew or
> > whatever. Note that this also happens if make_trouble() is as
> > simple as "my $x; $x = \$x;".
> > 
> > Regards,
> > 
> > -- Shlomi Fish
> > 
> > # Feeding XML::LibXML with an invalid file, triggering memory leaks
> > 
> > use strict;
> > use warnings;
> > 
> > use Devel::Leak;
> > 
> > use Encode;
> > use XML::LibXML;
> > 
> > use Carp;
> > 
> > binmode STDOUT, ':encoding(UTF-8)';
> > 
> > check_libxml_memory();
> > 
> > sub check_libxml_memory {
> >    print "running\n";
> >    my $handle;
> >    my $leaveCount = 0;
> >    my $enterCount = Devel::Leak::NoteSV($handle);
> >    print STDERR "\nENTER: $enterCount SVs\n";
> >    {
> >        make_trouble(); # Trace how loading a bad doc affects memory
> >    }
> >    $leaveCount = Devel::Leak::CheckSV($handle);
> >    print STDERR "\nLEAVE: $leaveCount SVs\n";
> > }
> > 
> > sub make_trouble {
> >    # Tries to load a bad XML file into XML::LibXML
> >    my $filenameIn = 'libxml-trouble-sample.html';
> >    local $/; #Read whole file
> >    open(my $FILEIN,'<', $filenameIn)
> >        or die "Can't read file '$filenameIn' [$!]\n";
> >    my $str = <$FILEIN>;
> >    close ($FILEIN);
> > 
> >    # Feeds the bad file to XML::LibXML.
> >    my $parser = XML::LibXML->new;
> >    my $success=1;
> >    # if recover is set to 0 or 1, the problem ceases to exist
> >    my $doc = $parser->parse_html_string($str,
> >        {recover => 2, encoding => 'UTF-8'}
> >    );
> > 
> >    return;
> > }
> > 
> > 1;
> > 
> > -- 
> > -----------------------------------------------------------------
> > Shlomi Fish       http://www.shlomifish.org/
> > Funny Anti-Terrorism Story - http://shlom.in/enemy
> > 
> > What is is. Perceive It. Integrate it. Act on it. Idealize it.
> >    — Leonard Peikoff
> > 
> > Please reply to list if it's a mailing list post -
> > http://shlom.in/reply .
> 



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Why I Love Perl - http://shlom.in/joy-of-perl

Xena the warrior princess can meet King David for breakfast and Julius Caesar
for lunch. Without time travel.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Reply via email to