develooper Front page | perl.perl5.porters | Postings from June 2009

[perl #66110] Perl debugger runs out of memory, hangs or segfaults on XML::Parser::Lite

From:
Bram via RT
Date:
June 28, 2009 02:14
Subject:
[perl #66110] Perl debugger runs out of memory, hangs or segfaults on XML::Parser::Lite
Message ID:
rt-3.6.HEAD-11910-1246137644-1540.66110-15-0@perl.org
A trimmed down version attached.

When you run it you may or may not get an 'Out of memory error!'.
In some of my tests adding or removing a newline was enough to make the 
error go away.
(It may also give a segfault. Not seen with this test but with ealier 
version I did get it )


Summary: running the test seems to depend on:
- the version of perl,
(- the configuration of perl,)
- the user running it,
- the filename,
- the command used in the debugger,

Test 1: perl-5.10.0, file: test.pl: user 'perl' and using 'next' in the 
debugger -> error
Test 2: perl-5.10.0, file: test.pl: user 'perl' and using 'run' in the 
debugger -> error
Test 3: perl-5.10.0, file: test.pl: user 'perl' and running with 
NonStop=1 -> no error

Test 4: perl-5.10.0, file: test.pl: user 'bram' and using 'next' in the 
debugger -> no error
Test 5: perl-5.10.0, file: test.pl: user 'bram' and using 'run' in the 
debugger -> no error
Test 6: perl-5.10.0, file: test.pl: user 'bram' and running with 
NonStop=1 -> error

Test 7: blead, file: test.pl: user 'perl' and using 'next' in the 
debugger -> no error
Test 8: blead, file: test.pl: user 'perl' and using 'run' in the 
debugger -> no error
Test 9: blead, file: test.pl: user 'perl' and running with NonStop=1 -> 
no error
Test 10: blead, file: test.pl: user 'bram' and using 'next' in the 
debugger -> no error
Test 11: blead, file: test.pl: user 'bram' and using 'run' in the 
debugger -> no error
Test 12: blead, file: test.pl: user 'bram' and running with NonStop=1 -
> no error

Test 13: blead, file: test_15.pl: user 'perl' and using 'next' in the 
debugger -> error
Test 14: blead, file: test_15.pl: user 'perl' and using 'run' in the 
debugger -> no error
Test 15: blead, file: test_15.pl: user 'perl' and running with 
NonStop=1 -> no error
Test 16: blead, file: test_15.pl: user 'bram' and using 'next' in the 
debugger -> error
Test 17: blead, file: test_15.pl: user 'bram' and using 'run' in the 
debugger -> no error
Test 18: blead, file: test_15.pl: user 'bram' and running with 
NonStop=1 -> no error

(Details are at end)


Valgrind (from Vincent):
$ ~/utils/valgrind/bin/valgrind perl5.10.0-dbg-thr -d z.pl 
==20460== Memcheck, a memory error detector.
==20460== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et 
al.
==20460== Using LibVEX rev 1900M, a library for dynamic binary 
translation.
==20460== Copyright (C) 2004-2009, and GNU GPL'd, by OpenWorks LLP.
==20460== Using valgrind-3.5.0.SVN, a dynamic binary instrumentation 
framework.
==20460== Copyright (C) 2000-2009, and GNU GPL'd, by Julian Seward et 
al.
==20460== For more details, rerun with: -v
==20460== 

Loading DB routines from perl5db.pl version 1.30000000000000004
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(z.pl:1): *c = sub {};
  DB<1> n
main::(z.pl:2): '' =~ m/(?{ c() })/;
  DB<1> n
main::((reeval 4)[z.pl:2]:1):
  DB<1> n
==20460== Invalid read of size 1
==20460==    at 0x4C22660: memcpy (mc_replace_strmem.c:482)
==20460==    by 0x478DE2: Perl_savepvn (util.c:944)
==20460==    by 0x55403B: Perl_regexec_flags (regexec.c:2174)
==20460==    by 0x4AE129: Perl_pp_match (pp_hot.c:1330)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x4A0FE0: S_run_body (perl.c:2379)
==20460==    by 0x4A090A: perl_run (perl.c:2302)
==20460==    by 0x421735: main (perlmain.c:113)
==20460==  Address 0x6c2c457 is 55 bytes inside a block of size 57 
free'd
==20460==    at 0x4C20DA0: free (vg_replace_malloc.c:323)
==20460==    by 0x477781: Perl_safesysfree (util.c:250)
==20460==    by 0x504CDA: Perl_leave_scope (scope.c:767)
==20460==    by 0x4AEC4B: Perl_pp_match (pp_hot.c:1506)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x55AFF4: S_regmatch (regexec.c:3687)
==20460==    by 0x554AF3: S_regtry (regexec.c:2325)
==20460==    by 0x553EB5: Perl_regexec_flags (regexec.c:2137)
==20460==    by 0x4AE129: Perl_pp_match (pp_hot.c:1330)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x4A0FE0: S_run_body (perl.c:2379)
==20460==    by 0x4A090A: perl_run (perl.c:2302)
==20460== 
==20460== Invalid read of size 1
==20460==    at 0x4C22668: memcpy (mc_replace_strmem.c:482)
==20460==    by 0x478DE2: Perl_savepvn (util.c:944)
==20460==    by 0x55403B: Perl_regexec_flags (regexec.c:2174)
==20460==    by 0x4AE129: Perl_pp_match (pp_hot.c:1330)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x4A0FE0: S_run_body (perl.c:2379)
==20460==    by 0x4A090A: perl_run (perl.c:2302)
==20460==    by 0x421735: main (perlmain.c:113)
==20460==  Address 0x6c2c456 is 54 bytes inside a block of size 57 
free'd
==20460==    at 0x4C20DA0: free (vg_replace_malloc.c:323)
==20460==    by 0x477781: Perl_safesysfree (util.c:250)
==20460==    by 0x504CDA: Perl_leave_scope (scope.c:767)
==20460==    by 0x4AEC4B: Perl_pp_match (pp_hot.c:1506)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x55AFF4: S_regmatch (regexec.c:3687)
==20460==    by 0x554AF3: S_regtry (regexec.c:2325)
==20460==    by 0x553EB5: Perl_regexec_flags (regexec.c:2137)
==20460==    by 0x4AE129: Perl_pp_match (pp_hot.c:1330)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x4A0FE0: S_run_body (perl.c:2379)
==20460==    by 0x4A090A: perl_run (perl.c:2302)
==20460== 
==20460== Invalid read of size 1
==20460==    at 0x4C22672: memcpy (mc_replace_strmem.c:482)
==20460==    by 0x478DE2: Perl_savepvn (util.c:944)
==20460==    by 0x55403B: Perl_regexec_flags (regexec.c:2174)
==20460==    by 0x4AE129: Perl_pp_match (pp_hot.c:1330)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x4A0FE0: S_run_body (perl.c:2379)
==20460==    by 0x4A090A: perl_run (perl.c:2302)
==20460==    by 0x421735: main (perlmain.c:113)
==20460==  Address 0x6c2c455 is 53 bytes inside a block of size 57 
free'd
==20460==    at 0x4C20DA0: free (vg_replace_malloc.c:323)
==20460==    by 0x477781: Perl_safesysfree (util.c:250)
==20460==    by 0x504CDA: Perl_leave_scope (scope.c:767)
==20460==    by 0x4AEC4B: Perl_pp_match (pp_hot.c:1506)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x55AFF4: S_regmatch (regexec.c:3687)
==20460==    by 0x554AF3: S_regtry (regexec.c:2325)
==20460==    by 0x553EB5: Perl_regexec_flags (regexec.c:2137)
==20460==    by 0x4AE129: Perl_pp_match (pp_hot.c:1330)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x4A0FE0: S_run_body (perl.c:2379)
==20460==    by 0x4A090A: perl_run (perl.c:2302)
==20460== 
==20460== Invalid read of size 1
==20460==    at 0x4C2267C: memcpy (mc_replace_strmem.c:482)
==20460==    by 0x478DE2: Perl_savepvn (util.c:944)
==20460==    by 0x55403B: Perl_regexec_flags (regexec.c:2174)
==20460==    by 0x4AE129: Perl_pp_match (pp_hot.c:1330)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x4A0FE0: S_run_body (perl.c:2379)
==20460==    by 0x4A090A: perl_run (perl.c:2302)
==20460==    by 0x421735: main (perlmain.c:113)
==20460==  Address 0x6c2c454 is 52 bytes inside a block of size 57 
free'd
==20460==    at 0x4C20DA0: free (vg_replace_malloc.c:323)
==20460==    by 0x477781: Perl_safesysfree (util.c:250)
==20460==    by 0x504CDA: Perl_leave_scope (scope.c:767)
==20460==    by 0x4AEC4B: Perl_pp_match (pp_hot.c:1506)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x55AFF4: S_regmatch (regexec.c:3687)
==20460==    by 0x554AF3: S_regtry (regexec.c:2325)
==20460==    by 0x553EB5: Perl_regexec_flags (regexec.c:2137)
==20460==    by 0x4AE129: Perl_pp_match (pp_hot.c:1330)
==20460==    by 0x476A10: Perl_runops_debug (dump.c:1931)
==20460==    by 0x4A0FE0: S_run_body (perl.c:2379)
==20460==    by 0x4A090A: perl_run (perl.c:2302)
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.  
  DB<1> 







The details:

perl -V used in the following tests:
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.33.3, archname=i686-linux
    uname='linux wizbit 2.4.33.3 #1 sun jan 21 11:41:03 cet 2007 i686 
pentium3 i386 gnulinux '
    config_args='-Dprefix=/opt/perl/5.10.0 -Dusedevel=y -de'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include -
D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.4.6', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.3.6.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.3.6'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
                        USE_LARGE_FILES USE_PERLIO
  Built under linux
  Compiled at Feb 27 2008 15:59:27
  @INC:
    /opt/perl/5.10.0/lib/5.10.0/i686-linux
    /opt/perl/5.10.0/lib/5.10.0
    /opt/perl/5.10.0/lib/site_perl/5.10.0/i686-linux
    /opt/perl/5.10.0/lib/site_perl/5.10.0
    .

Test 1: perl-5.10.0, file: test.pl: user 'perl' and using 'next' in the 
debugger -> error
perl@wizbit:/tmp/RT-66110$ /opt/perl/bin/perl5100 -d test.pl

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test.pl:1):      *c = sub {};
  DB<1> n
main::(test.pl:2):      '' =~ m/(?{ c() })/;
  DB<1> n
main::((reeval 4)[test.pl:2]:1):
  DB<1> n
Out of memory!
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
*** glibc detected *** corrupted double-linked list: 0xb7edd878 ***
Aborted
perl@wizbit:/tmp/RT-
66110$                                                         

Test 2: perl-5.10.0, file: test.pl: user 'perl' and using 'run' in the 
debugger -> error
perl@wizbit:/tmp/RT-66110$ /opt/perl/bin/perl5100 -d test.pl

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test.pl:1):      *c = sub {};
  DB<1> r
Out of memory!
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
*** glibc detected *** corrupted double-linked list: 0xb7ea7878 ***
Aborted
perl@wizbit:/tmp/RT-
66110$                                                         


Test 3: perl-5.10.0, file: test.pl: user 'perl' and running with 
NonStop=1 -> no error
perl@wizbit:/tmp/RT-66110$ PERLDB_OPTS="NonStop=1" /opt/perl/bin/
perl5100 -d test.pl
perl@wizbit:/tmp/RT-
66110$                                                         


Test 4: perl-5.10.0, file: test.pl: user 'bram' and using 'next' in the 
debugger -> no error

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test.pl:1):      *c = sub {};
  DB<1> n
main::(test.pl:2):      '' =~ m/(?{ c() })/;
  DB<1> n
main::((reeval 4)[test.pl:2]:1):
  DB<1> n
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
bram@wizbit:/tmp/RT-66110$


Test 5: perl-5.10.0, file: test.pl: user 'bram' and using 'run' in the 
debugger -> no error

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test.pl:1):      *c = sub {};
  DB<1> r
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
bram@wizbit:/tmp/RT-66110$


Test 6: perl-5.10.0, file: test.pl: user 'bram' and running with 
NonStop=1 -> error
bram@wizbit:/tmp/RT-66110$ PERLDB_OPTS="NonStop=1" /opt/perl/bin/
perl5100 -d test.pl
Out of memory!
bram@wizbit:/tmp/RT-66110$


Test 7: blead, file: test.pl: user 'perl' and using 'next' in the 
debugger -> no error
perl@wizbit:/tmp/RT-66110$ /opt/perl/2009-06-18/perl -I /opt/perl/2009-
06-18/lib -d test.pl

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test.pl:1):      *c = sub {};
  DB<1> n
main::(test.pl:2):      '' =~ m/(?{ c() })/;
  DB<1> n
main::((reeval 4)[test.pl:2]:1):
  DB<1> n
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
perl@wizbit:/tmp/RT-66110$


Test 8: blead, file: test.pl: user 'perl' and using 'run' in the 
debugger -> no error
perl@wizbit:/tmp/RT-66110$ /opt/perl/2009-06-18/perl -I /opt/perl/2009-
06-18/lib -d test.pl

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test.pl:1):      *c = sub {};
  DB<1> r
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
perl@wizbit:/tmp/RT-66110$


Test 9: blead, file: test.pl: user 'perl' and running with NonStop=1 -> 
no error
perl@wizbit:/tmp/RT-66110$ PERLDB_OPTS="NonStop=1" /opt/perl/2009-06-18/
perl -I /opt/perl/2009-06-18/lib -d test.pl
perl@wizbit:/tmp/RT-66110$


Test 10: blead, file: test.pl: user 'bram' and using 'next' in the 
debugger -> no error
bram@wizbit:/tmp/RT-66110$ /opt/perl/2009-06-18/perl -I /opt/perl/2009-
06-18/lib -d test.pl

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test.pl:1):      *c = sub {};
  DB<1> n
main::(test.pl:2):      '' =~ m/(?{ c() })/;
  DB<1> n
main::((reeval 4)[test.pl:2]:1):
  DB<1> n
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
bram@wizbit:/tmp/RT-66110$  

Test 11: blead, file: test.pl: user 'bram' and using 'run' in the 
debugger -> no error
bram@wizbit:/tmp/RT-66110$ /opt/perl/2009-06-18/perl -I /opt/perl/2009-
06-18/lib -d test.pl

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test.pl:1):      *c = sub {};
  DB<1> r
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
bram@wizbit:/tmp/RT-
66110$                                                                               


Test 12: blead, file: test.pl: user 'bram' and running with NonStop=1 -
> no error
bram@wizbit:/tmp/RT-66110$ PERLDB_OPTS="NonStop=1" /opt/perl/2009-06-18/
perl -I /opt/perl/2009-06-18/lib -d test.pl
bram@wizbit:/tmp/RT-66110$         


Changing the name of the test script: test.pl -> test_15.pl

$ md5sum test.pl test_15.pl
950ddaee20bd8f2c6275abb4f252f4a3  test.pl
950ddaee20bd8f2c6275abb4f252f4a3  test_15.pl

$ diff -Naur test.pl test_15.pl
$


Test 13: blead, file: test_15.pl: user 'perl' and using 'next' in the 
debugger -> error
perl@wizbit:/tmp/RT-66110$ /opt/perl/2009-06-18/perl -I /opt/perl/2009-
06-18/lib -d test_15.pl

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test_15.pl:1):   *c = sub {};
  DB<1> n
main::(test_15.pl:2):   '' =~ m/(?{ c() })/;
  DB<1> n
main::((reeval 4)[test_15.pl:2]:1):
1:
  DB<1> n
Out of memory!
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
*** glibc detected *** corrupted double-linked list: 0xb8030878 ***
Aborted
perl@wizbit:/tmp/RT-66110$                     

Test 14: blead, file: test_15.pl: user 'perl' and using 'run' in the 
debugger -> no error
perl@wizbit:/tmp/RT-66110$ /opt/perl/2009-06-18/perl -I /opt/perl/2009-
06-18/lib -d test_15.pl

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test_15.pl:1):   *c = sub {};
  DB<1> r
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
perl@wizbit:/tmp/RT-66110$


Test 15: blead, file: test_15.pl: user 'perl' and running with 
NonStop=1 -> no error
perl@wizbit:/tmp/RT-66110$ PERLDB_OPTS="NonStop=1" /opt/perl/2009-06-18/
perl -I /opt/perl/2009-06-18/lib -d test_15.pl
perl@wizbit:/tmp/RT-66110$


Test 16: blead, file: test_15.pl: user 'bram' and using 'next' in the 
debugger -> error
bram@wizbit:/tmp/RT-66110$ /opt/perl/2009-06-18/perl -I /opt/perl/2009-
06-18/lib -d test_15.pl

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test_15.pl:1):   *c = sub {};
  DB<1> n
main::(test_15.pl:2):   '' =~ m/(?{ c() })/;
  DB<1> n
main::((reeval 4)[test_15.pl:2]:1):
1:
  DB<1> n
Out of memory!
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
*** glibc detected *** corrupted double-linked list: 0xb7f9b878 ***
Aborted
bram@wizbit:/tmp/RT-66110$ 

Test 17: blead, file: test_15.pl: user 'bram' and using 'run' in the 
debugger -> no error
bram@wizbit:/tmp/RT-66110$ /opt/perl/2009-06-18/perl -I /opt/perl/2009-
06-18/lib -d test_15.pl

Loading DB routines from perl5db.pl version 1.33
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(test_15.pl:1):   *c = sub {};
  DB<1> r
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.
  DB<1> q
bram@wizbit:/tmp/RT-66110$


Test 18: blead, file: test_15.pl: user 'bram' and running with 
NonStop=1 -> no error
bram@wizbit:/tmp/RT-66110$ PERLDB_OPTS="NonStop=1" /opt/perl/2009-06-18/
perl -I /opt/perl/2009-06-18/lib -d test_15.pl
bram@wizbit:/tmp/RT-66110$



Best regards,

Bram



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