[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Seg fault with HTML::Parser



Gisle Aas <gisle@ActiveState.com> writes:

> What is happening is that pp_repeat will relocate the stack in this
> case.  I think the problem is that something else keeps a stale stack
> pointer around.  A missing SPAGAIN somewhere.  The C stack looks like
> this when we enter pp_repeat:
> 
> Breakpoint 1, Perl_pp_repeat () at pp.c:1392
> 1392      dSP; dATARGET; tryAMAGICbin(repeat,opASSIGN);
> (gdb) bt
> #0  Perl_pp_repeat () at pp.c:1392
> #1  0x080b4f69 in Perl_runops_debug () at dump.c:1443
> #2  0x080640b0 in S_call_body (myop=0xbffff580, is_eval=0) at perl.c:2096
> #3  0x08063d13 in Perl_call_sv (sv=0x81dec3c, flags=134) at perl.c:2014
> #4  0x401ff72e in report_event (p_state=0x8183b48, event=E_END, beg=0x8191320 "</TD>", end=0x8191325 "",
>     tokens=0xbffff670, num_tokens=1, self=0x818a75c) at hparser.c:547
> #5  0x4020179f in parse_end (p_state=0x8183b48, beg=0x8191320 "</TD>", end=0x8191325 "", self=0x818a75c)
>     at hparser.c:1330
> #6  0x40201e41 in parse_buf (p_state=0x8183b48, beg=0x8191320 "</TD>", end=0x8191325 "", self=0x818a75c)
>     at hparser.c:1551
> #7  0x402022c2 in parse (p_state=0x8183b48, chunk=0x81debc4, self=0x818a75c) at hparser.c:1658
> #8  0x40202f15 in XS_HTML__Parser_parse (cv=0x81cbbb8) at Parser.xs:265

This is the one that forgot to refresh the stack pointer.  This patch
to HTML-Parser make the problem go away:

Index: Parser.xs
===================================================================
RCS file: /cvsroot/libwww-perl/html-parser/Parser.xs,v
retrieving revision 2.118
diff -u -p -u -r2.118 Parser.xs
--- Parser.xs	15 Aug 2003 16:56:20 -0000	2.118
+++ Parser.xs	27 Oct 2003 20:58:08 -0000
@@ -258,11 +258,13 @@ parse(self, chunk)
 		    len = 0;
                 }
 		parse(aTHX_ p_state, len ? chunk : 0, self);
+	        SPAGAIN;
 
             } while (len && !p_state->eof);
         }
 	else {
 	    parse(aTHX_ p_state, chunk, self);
+            SPAGAIN;
         }
         p_state->parsing = 0;
 	if (p_state->eof) {

Thanks for listening :)  I will upload an updated HTML::Parser soon.

Regards,
Gisle

> #9  0x080d5f0b in Perl_pp_entersub () at pp_hot.c:2763
> #10 0x080b4f69 in Perl_runops_debug () at dump.c:1443
> #11 0x080633cc in S_run_body (oldscope=1) at perl.c:1732
> #12 0x08062f34 in perl_run (my_perl=0x817bd88) at perl.c:1651
> #13 0x0805e79d in main (argc=2, argv=0xbffff9b4, env=0xbffff9c0) at perlmain.c:86
> #14 0x400b7336 in __libc_start_main (main=0x805e700 <main>, argc=2, ubp_av=0xbffff9b4, init=0x805d7c4 <_init>,
>     fini=0x81543a0 <_fini>, rtld_fini=0x4000d2fc <_dl_fini>, stack_end=0xbffff9ac) at ../sysdeps/generic/libc-start.c:129



Reply to: