Skip Menu |

This queue is for tickets about the Cache-Mmap CPAN distribution.

Report information
The Basics
Id: 95940
Status: open
Priority: 0/
Queue: Cache-Mmap

People
Owner: Nobody in particular
Requestors: ntyni [...] iki.fi
Cc: gregoa [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.11
Fixed in: (no value)



Subject: Test suite segfaults with Perl 5.20.0-RC1
I don't know why the smokers don't seem to have caught this, but it's perfectly reproducible for me on mostly current Debian unstable. I'll report this on perl5-porters too, filing this for reference. PERL_DL_NONLAZY=1 /opt/perl/5.20/5.20.0-RC1/nothreads-debugging/bin/perl "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/01simple.t ... Failed 36/46 subtests t/02entries.t .. Failed 3/6 subtests t/03corrupt.t .. Failed 23/26 subtests t/04utf8.t ..... Failed 11/13 subtests t/05keep.t ..... Failed 7/9 subtests % /opt/perl/5.20/5.20.0-RC1/nothreads-debugging/bin/perl -Iblib/lib -Iblib/arch t/01simple.t 1..46 ok 1 - use Cache::Mmap; ok 2 - creating cache file ok 3 - default buckets ok 4 - default bucketsize ok 5 - default pagesize ok 6 - default strings ok 7 - default expiry ok 8 - default cachenegative ok 9 - default writethrough ok 10 - cache is empty zsh: segmentation fault (core dumped) /opt/perl/5.20/5.20.0-RC1/nothreads-debugging/bin/perl -Iblib/lib -Iblib/arch Program received signal SIGSEGV, Segmentation fault. 0x00000000005765ea in S_unshare_hek_or_pvn (hek=0x7ffff7febff8, str=0x0, len=0, hash=0) at hv.c:2746 2746 assert (he->shared_he_he.hent_hek == hek); (gdb) bt #0 0x00000000005765ea in S_unshare_hek_or_pvn (hek=0x7ffff7febff8, str=0x0, len=0, hash=0) at hv.c:2746 #1 0x00000000005765a0 in Perl_unshare_hek (hek=0x7ffff7febff8) at hv.c:2719 #2 0x00000000005bc6d3 in S_sv_uncow (sv=0xd0b160, flags=0) at sv.c:5046 #3 0x00000000005bc779 in Perl_sv_force_normal_flags (sv=0xd0b160, flags=0) at sv.c:5079 #4 0x00000000005d8d44 in Perl_sv_pvn_force_flags (sv=0xd0b160, lp=0x7fffffffe2f0, flags=0) at sv.c:9615 #5 0x000000000055282b in Perl_magic_setsubstr (sv=0xc86a18, mg=0xe06940) at mg.c:2228 #6 0x0000000000548443 in Perl_mg_set (sv=0xc86a18) at mg.c:279 #7 0x000000000057e9ff in Perl_pp_sassign () at pp_hot.c:224 #8 0x0000000000535515 in Perl_runops_debug () at dump.c:2428 #9 0x0000000000457fb1 in S_run_body (oldscope=1) at perl.c:2456 #10 0x00000000004575e2 in perl_run (my_perl=0xa32010) at perl.c:2372 #11 0x000000000041d165 in main (argc=4, argv=0x7fffffffe828, env=0x7fffffffe850) at perlmain.c:114 Summary of my perl5 (revision 5 version 20 subversion 0) configuration: Commit id: 1da5bb70ab48e3af769fcf1266b774a7dbe63a88 Platform: osname=linux, osvers=3.14-1-amd64, archname=x86_64-linux uname='linux estella 3.14-1-amd64 #1 smp debian 3.14.4-1 (2014-05-13) x86_64 gnulinux ' config_args='-des -Dprefix=/opt/perl/5.20/5.20.0-RC1/nothreads-debugging -DDEBUGGING -Doptimize=-O0' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O0 -g', cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.8.2', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=libc-2.18.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.18' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O0 -g -L/usr/local/lib -fstack-protector' Characteristics of this binary (from libperl): Compile-time options: DEBUGGING HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF Locally applied patches: RC1 Built under linux Compiled at May 24 2014 22:29:02 @INC: /opt/perl/5.20/5.20.0-RC1/nothreads-debugging/lib/site_perl/5.20.0/x86_64-linux /opt/perl/5.20/5.20.0-RC1/nothreads-debugging/lib/site_perl/5.20.0 /opt/perl/5.20/5.20.0-RC1/nothreads-debugging/lib/5.20.0/x86_64-linux /opt/perl/5.20/5.20.0-RC1/nothreads-debugging/lib/5.20.0
Subject: Re: [rt.cpan.org #95940] AutoReply: Test suite segfaults with Perl 5.20.0-RC1
Date: Sun, 25 May 2014 19:59:16 +0300
To: Bugs in Cache-Mmap via RT <bug-Cache-Mmap [...] rt.cpan.org>
From: Niko Tyni <ntyni [...] iki.fi>
On Sat, May 24, 2014 at 03:41:40PM -0400, Bugs in Cache-Mmap via RT wrote: Show quoted text
> % /opt/perl/5.20/5.20.0-RC1/nothreads-debugging/bin/perl -Iblib/lib -Iblib/arch t/01simple.t > 1..46 > ok 1 - use Cache::Mmap; > ok 2 - creating cache file > ok 3 - default buckets > ok 4 - default bucketsize > ok 5 - default pagesize > ok 6 - default strings > ok 7 - default expiry > ok 8 - default cachenegative > ok 9 - default writethrough > ok 10 - cache is empty > zsh: segmentation fault (core dumped) /opt/perl/5.20/5.20.0-RC1/nothreads-debugging/bin/perl -Iblib/lib -Iblib/arch
Bisecting indicates this broke between 5.19.2 and 5.19.3 with http://perl5.git.perl.org/perl.git/commit/7fa949d0cc67253f8eb6849414789201b5ba722c CPAN tester reports from last night show it's working for Andreas. I haven't figured out yet why it's failing here. Maybe the amount of memory available or something like that? I have 8G here FWIW. 7fa949d0cc67253f8eb6849414789201b5ba722c is the first bad commit commit 7fa949d0cc67253f8eb6849414789201b5ba722c Author: Father Chrysostomos <sprout@cpan.org> Date: Sun Aug 11 00:02:34 2013 -0700 Mark COWable constants as COWable at compile time This allows ‘$_ = "hello"’ to do COW without having to copy that constant. The reason this did not work before is that we never do copy-on-write with existing read-only scalars that are not already marked COW, as doing so modifies the string buffer, which the read-only flag may be intended to protect. At compile time, most constants start out mutable and are made read- only in ck_svconst. So there we can check that the constant is indeed still mutable (and COWable) and mark it as a COW scalar before making it read-only. :040000 040000 ef758ccb95d17ad9b2282be2e4c0b8583178cfa7 1f13e7e34bf6050a88fe578aa9ea662758901a5a M ext :100644 100644 f5a274fc1384517c44fc7f8730be274bdc62777d fd8868f915ac3302ab99e1f880eef0baea209487 M op.c -- Niko Tyni ntyn@debian.org
Subject: Re: [rt.cpan.org #95940] AutoReply: Test suite segfaults with Perl 5.20.0-RC1
Date: Sun, 25 May 2014 23:01:05 +0300
To: Bugs in Cache-Mmap via RT <bug-Cache-Mmap [...] rt.cpan.org>
From: Niko Tyni <ntyni [...] iki.fi>
On Sun, May 25, 2014 at 07:59:16PM +0300, Niko Tyni wrote: Show quoted text
> CPAN tester reports from last night show it's working for Andreas. I > haven't figured out yet why it's failing here. Maybe the amount of memory > available or something like that? I have 8G here FWIW.
It seems to be locale dependent, but in a weird way. In a Ubuntu 14.04 chroot, it happens with LC_CTYPE=fi_FI.UTF-8, but not with LC_CTYPE=POSIX. However, on my Debian unstable host it seems to happen with all locales. -- Niko Tyni ntyni@debian.org
From: davem [...] iabyn.com
Copying from my reply on p5p: Its a bug in Cache-Mmap; it does, at the perl level, the equivalent of $buf=''; mmap($buf,....); where mmap() is an XS function that does: SvUPGRADE(var,SVt_PV); SvPVX(var)=(char*)addr; /* a recently mmapped buffer */ SvCUR_set(var,len); SvLEN_set(var,0); SvPOK_only(var); After FC's commit, $buf gets marked as COW, since its a copy of a COWable constant (the constant string "") and mmap() never unsets this flag before stealing its buffer. So later on when it applies substr() to $buf, the var is assumed to be COW and bad things happen to it. The correct usage is still up for debate (see Leon's use case in rt.perl.org tickets #116407 and #116925), but calling SvPV_force() first would be a good first step (although that will cause the previous contents of PVX() to leak). It might be better for Mmap.pm to call mmap() with an undef value rather than assigning "" to it first.