Perl crashes with ‘double free or corruption’ when using git-svn

If you update git from 1.7 to 1.8.x your git-svn might output a perl backtrace as shown below.

*** Error in `/usr/bin/perl': double free or corruption (!prev): 0x00000000019f4a20 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x72ecf)[0x7f3806858ecf]
/usr/lib/libc.so.6(+0x7869e)[0x7f380685e69e]
/usr/lib/libc.so.6(+0x79377)[0x7f380685f377]
/usr/lib/libapr-1.so.0(apr_allocator_destroy+0x1d)[0x7f3803b6be2d]
/usr/lib/libapr-1.so.0(apr_pool_terminate+0x30)[0x7f3803b6c820]
/usr/lib/perl5/vendor_perl/auto/SVN/_Core/_Core.so(_wrap_apr_terminate+0x50)[0x7f3804d646a0]
/usr/lib/perl5/core_perl/CORE/libperl.so(Perl_pp_entersub+0x596)[0x7f3806c52556]
/usr/lib/perl5/core_perl/CORE/libperl.so(Perl_runops_standard+0x16)[0x7f3806c4ab66]
/usr/lib/perl5/core_perl/CORE/libperl.so(Perl_call_sv+0x3b0)[0x7f3806bdc280]
/usr/lib/perl5/core_perl/CORE/libperl.so(Perl_call_list+0x2c7)[0x7f3806bde357]
/usr/lib/perl5/core_perl/CORE/libperl.so(perl_destruct+0x1321)[0x7f3806bdf971]
/usr/bin/perl(main+0x111)[0x400e01]
/usr/lib/libc.so.6(__libc_start_main+0xf5)[0x7f3806807bc5]
/usr/bin/perl[0x400e71]
======= Memory map: ========
00400000-00402000 r-xp 00000000 08:03 11281949                           /usr/bin/perl
00601000-00602000 r--p 00001000 08:03 11281949                           /usr/bin/perl
00602000-00603000 rw-p 00002000 08:03 11281949                           /usr/bin/perl
007a5000-01a6b000 rw-p 00000000 00:00 0                                  [heap]
7f37f806f000-7f37f8074000 r-xp 00000000 08:03 11275499                   /usr/lib/libnss_dns-2.18.so
7f37f8074000-7f37f8273000 ---p 00005000 08:03 11275499                   /usr/lib/libnss_dns-2.18.so
7f37f8273000-7f37f8274000 r--p 00004000 08:03 11275499                   /usr/lib/libnss_dns-2.18.so

To fix it open /usr/share/perl5/vendor_perl/Git/SVN/Ra.pm and scroll down to the following section.

BEGIN {
        # enforce temporary pool usage for some simple functions
        no strict 'refs';
        for my $f (qw/rev_proplist get_latest_revnum get_uuid get_repos_root
                      get_file/) {
                my $SUPER = "SUPER::$f";
                *$f = sub {
                        my $self = shift;
                        my $pool = SVN::Pool->new;
                        my @ret = $self->$SUPER(@_,$pool);
                        $pool->clear;
                        wantarray ? @ret : $ret[0];
                };
        }
}

sub _auth_providers () {

Now right before the function _auth_providers add

END {
  $RA = undef;
}

That should solve the problem.

1 Comment

  1. Günther

    This is probably a bug in Perl or in libapr-1 — programming languages with garbage collection should under normal circumstances not have memory corruption errors. — double free is just referring to the fact that someone tried to call free() twice on the same pointer. (See man 3 free for the C memory primitives.)

    Looks like it’s been reported before though:
    http://mail-archives.apache.org/mod_mbox/subversion-users/201307.mbox/%3CCAJC6wRu0xHZMKgvkTDNV4qXmvQv9WCArks6mXh+inEoChL23+w@mail.gmail.com%3E
    https://bugs.archlinux.org/task/36070

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>