Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I realise this is a horrible example. It was part of a much bigger bit of code and I've tried to reduce it as much as possible but almost anything I change now makes it work. It works in all versions of perl before 5.16.0 I've tried and also fails in 5.16.1.

use strict; use warnings; use v5.16.0; # change any of the numbers below 305 or 1205) and it works. # it is not stack size as I've changed that with ulimit my @md = (1..305); my @mp = (1000..1205); print "market detail: ", scalar(@md), "\n"; print "market price: ", scalar(@mp), "\n"; my $path = "/tmp/x"; mkdir $path or die "making $path, $!"; foreach (@md) { open(my $f, ">", "$path/md_$_.dat"); close $f; } foreach (@mp) { open(my $f, ">", "$path/mp_$_.dat"); close $f; } chdir $path or die "failed to chdir to $path"; my @b = glob(qq{$path/mp_[0123456789]*.dat $path/md_[0123456789]*.dat}); print scalar(@b), "\n";

which completes with:

*** glibc detected *** perl: double free or corruption (!prev): 0x09ca +5390 *** ======= Backtrace: ========= /lib/i386-linux-gnu/libc.so.6(+0x6ff22)[0xb7639f22] /lib/i386-linux-gnu/libc.so.6(+0x70bc2)[0xb763abc2] /lib/i386-linux-gnu/libc.so.6(cfree+0x6d)[0xb763dcad] perl(Perl_av_extend+0x19d)[0x80d40dd] perl(Perl_stack_grow+0x32)[0x80ff512] perl(Perl_pp_padav+0x114)[0x80f05c4] perl(Perl_runops_standard+0xb)[0x80d5a3b] perl(perl_run+0x325)[0x807ca15] perl(main+0x105)[0x8061c45] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb75e3113] perl[0x8061c75] ======= Memory map: ======== 08048000-0818b000 r-xp 00000000 08:01 15075154 /home/martin/perl5/pe +rlbrew/perls/perl-5.16.0/bin/perl 0818b000-0818c000 r--p 00142000 08:01 15075154 /home/martin/perl5/pe +rlbrew/perls/perl-5.16.0/bin/perl 0818c000-0818f000 rw-p 00143000 08:01 15075154 /home/martin/perl5/pe +rlbrew/perls/perl-5.16.0/bin/perl 09c81000-09ce4000 rw-p 00000000 00:00 0 [heap] b7100000-b7121000 rw-p 00000000 00:00 0 b7121000-b7200000 ---p 00000000 00:00 0 b7214000-b7230000 r-xp 00000000 08:01 12756973 /lib/i386-linux-gnu/l +ibgcc_s.so.1 b7230000-b7231000 r--p 0001b000 08:01 12756973 /lib/i386-linux-gnu/l +ibgcc_s.so.1 b7231000-b7232000 rw-p 0001c000 08:01 12756973 /lib/i386-linux-gnu/l +ibgcc_s.so.1 b7251000-b7256000 r-xp 00000000 08:01 15082170 /home/martin/perl5/pe +rlbrew/perls/perl-5.16.0/lib/5.16.0/i686-linux/auto/File/Glob/Glob.so b7256000-b7257000 r--p 00004000 08:01 15082170 /home/martin/perl5/pe +rlbrew/perls/perl-5.16.0/lib/5.16.0/i686-linux/auto/File/Glob/Glob.so b7257000-b7258000 rw-p 00005000 08:01 15082170 /home/martin/perl5/pe +rlbrew/perls/perl-5.16.0/lib/5.16.0/i686-linux/auto/File/Glob/Glob.so b7258000-b7298000 r--p 006a5000 08:01 12665422 /usr/lib/locale/local +e-archive b7298000-b73c9000 r--p 00446000 08:01 12665422 /usr/lib/locale/local +e-archive b73c9000-b75c9000 r--p 00000000 08:01 12665422 /usr/lib/locale/local +e-archive b75c9000-b75ca000 rw-p 00000000 00:00 0 b75ca000-b7742000 r-xp 00000000 08:01 12755031 /lib/i386-linux-gnu/l +ibc-2.13.so b7742000-b7744000 r--p 00178000 08:01 12755031 /lib/i386-linux-gnu/l +ibc-2.13.so b7744000-b7745000 rw-p 0017a000 08:01 12755031 /lib/i386-linux-gnu/l +ibc-2.13.so b7745000-b7748000 rw-p 00000000 00:00 0 b7748000-b7750000 r-xp 00000000 08:01 12755033 /lib/i386-linux-gnu/l +ibcrypt-2.13.so b7750000-b7751000 r--p 00007000 08:01 12755033 /lib/i386-linux-gnu/l +ibcrypt-2.13.so b7751000-b7752000 rw-p 00008000 08:01 12755033 /lib/i386-linux-gnu/l +ibcrypt-2.13.so b7752000-b777a000 rw-p 00000000 00:00 0 b777a000-b77a2000 r-xp 00000000 08:01 12755035 /lib/i386-linux-gnu/l +ibm-2.13.so b77a2000-b77a3000 r--p 00028000 08:01 12755035 /lib/i386-linux-gnu/l +ibm-2.13.so b77a3000-b77a4000 rw-p 00029000 08:01 12755035 /lib/i386-linux-gnu/l +ibm-2.13.so b77a4000-b77a7000 r-xp 00000000 08:01 12755034 /lib/i386-linux-gnu/l +ibdl-2.13.so b77a7000-b77a8000 r--p 00002000 08:01 12755034 /lib/i386-linux-gnu/l +ibdl-2.13.so b77a8000-b77a9000 rw-p 00003000 08:01 12755034 /lib/i386-linux-gnu/l +ibdl-2.13.so b77c7000-b77c8000 r--p 003fc000 08:01 12665422 /usr/lib/locale/local +e-archive b77c8000-b77ca000 rw-p 00000000 00:00 0 b77ca000-b77cb000 r-xp 00000000 00:00 0 [vdso] b77cb000-b77e9000 r-xp 00000000 08:01 12755028 /lib/i386-linux-gnu/l +d-2.13.so b77e9000-b77ea000 r--p 0001d000 08:01 12755028 /lib/i386-linux-gnu/l +d-2.13.so b77ea000-b77eb000 rw-p 0001e000 08:01 12755028 /lib/i386-linux-gnu/l +d-2.13.so bf9cf000-bf9f0000 rw-p 00000000 00:00 0 [stack] Aborted

valgrind says:

==26288== Invalid write of size 4 ==26288== at 0x4029C3E: memcpy (mc_replace_strmem.c:635) ==26288== by 0x4032D9E: iterate (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/lib/5.16.0/i686-linux/au +to/File/Glob/Glob.so) ==26288== by 0x8111B36: Perl_pp_glob (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x40C8112: (below main) (libc-start.c:226) ==26288== Address 0x42c3730 is 0 bytes after a block of size 2,032 al +loc'd ==26288== at 0x4028876: malloc (vg_replace_malloc.c:236) ==26288== by 0x80BAB88: Perl_safesysmalloc (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x80D4087: Perl_av_extend (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x80FF511: Perl_stack_grow (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x8108483: Perl_pp_flop (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x80D5A3A: Perl_runops_standard (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x806B701: Perl_list (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x806BC6F: S_listkids (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x806B796: Perl_list (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x806E1DA: Perl_newASSIGNOP (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x809C316: Perl_yyparse (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288== by 0x807B9DA: perl_parse (in /home/martin/perl5/perlbrew/perls/perl-5.16.0/bin/perl) ==26288==

UPDATE: also fails in 5.17.4


In reply to "double free or corruption" in Perl 5.16.0 but not in 5.14.2 by mje

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (17)
    As of 2015-07-06 14:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (75 votes), past polls