Re: HTML::Parser crashes when ->new is called from start_h

[email protected] (Gisle Aas) Mon, 8 Nov 2010 19:29:06 +0100
Newsgroups perl.libwww
Message-ID <[email protected]>
Quite a convoluted example.  I now have the example that segfaults down to this; still investigating to understand what happens.

#!/usr/bin/perl 

use strict;
use HTML::Parser;

{
    package Parseable;
    my $this;

    sub new {
	if (!$this) {
	    $this = bless {};
	}

	$this->{parser} = new HTML::Parser(
	    start_h => [sub {
		warn "before new p";
		Parseable->new;
		warn "after new p";
	    }],
	); 

	$this;
    }
}

Parseable->new->{parser}->parse(q(<foo>));



On Nov 7, 2010, at 21:10 , Father Chrysostomos wrote:

> I *think* this is a bug in HTML::Parser, but I’m not sure.
> 
> Attached is a script that reproduces the bug. It is reduced from a script submitted to <http://rt.perl.org/rt3/Ticket/Display.html?id=78728>. I cannot reduce it any further while still producing the bug reliably.
> 
> When a new HTML::Parser object is created from within a start handler (start_h), p_state->buf in the original parser gets overwritten somehow.
> <crawl.pl>