develooper Front page | perl.perl5.porters | Postings from May 2016

[perl #128189] Assert fail in sv.c with no further symptoms: et''/$0{\0}

Thread Previous
From:
Dan Collins
Date:
May 19, 2016 21:45
Subject:
[perl #128189] Assert fail in sv.c with no further symptoms: et''/$0{\0}
Message ID:
rt-4.0.18-12133-1463694312-547.128189-75-0@perl.org
# New Ticket Created by  Dan Collins 
# Please include the string:  [perl #128189]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=128189 >


I have compiled bleadperl with the afl-gcc compiler using:

./Configure -Dusedevel -Dprefix='/usr/local/perl-afl' -Dcc='ccache afl-gcc' -Uuselongdouble -Duse64bitall -Doptimize=-g -Uversiononly -Uman1dir -Uman3dir -Dusequadmath -DDEBUGGING -des
AFL_HARDEN=1 make && make test

And then fuzzed the resulting binary using:

AFL_NO_VAR_CHECK=1 afl-fuzz -i in -o out bin/perl -t -W @@

After reducing testcases using `afl-tmin` and performing additional minimization by hand, I have located the following testcase that triggers an assert fail in debugging builds of the perl interpreter. The testcase is the file below. On normal builds, this exits with the expected error. On debug builds with -W, this returns an assert fail.

dcollins@nightshade64:~$ perl/miniperl -W -e 'e t""/$0{\0}'
Use of uninitialized value $0{"\200\350{\2\0\0\0\0\1\0\0\0\1\21"...} in division (/) at -e line 1.
Argument "" isn't numeric in division (/) at -e line 1.
Illegal division by zero at -e line 1.
dcollins@nightshade64:~$ perldebug/miniperl -W -e 'e t""/$0{\0}'
miniperl: sv.c:15687: Perl_varname: Assertion `PL_valid_types_PVX[((svtype)((_svcur)->sv_flags & 0xff)) & 0xf] || ((svtype)((_svcur)->sv_flags & 0xff)) == SVt_REGEXP' failed.
Aborted

Debugging tool output is below. A git bisect was attempted, but this persists as far back as 5.14.0, which is also as far back as I'm able to compile right now.


**GDB**

dcollins@nightshade64:~$ gdb --args perldebug/miniperl -W -e 'e t""/$0{\0}'
GNU gdb (GDB) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from perldebug/miniperl...done.
(gdb) run
Starting program: /home/dcollins/perldebug/miniperl -W -e e\ t\"\"/\$0\{\\0\}
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
miniperl: sv.c:15687: Perl_varname: Assertion `PL_valid_types_PVX[((svtype)((_svcur)->sv_flags & 0xff)) & 0xf] || ((svtype)((_svcur)->sv_flags & 0xff)) == SVt_REGEXP' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff6cf9478 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0  0x00007ffff6cf9478 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff6cfa8fa in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x00007ffff6cf23a7 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x00007ffff6cf2452 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x00000000005fee9c in Perl_varname (gv=0xa96868, gvtype=37 '%', targ=0, keyname=0xa96bb0, aindex=0, subscript_type=3) at sv.c:15686
#5  0x000000000060038c in S_find_uninit_var (obase=0xa9fd08, uninit_sv=0xa7e840 <PL_sv_undef>, match=false, desc_p=0x7fffffffdf78) at sv.c:15926
#6  0x00000000006018dd in S_find_uninit_var (obase=0xa9fcc0, uninit_sv=0xa7e840 <PL_sv_undef>, match=false, desc_p=0x7fffffffdf78) at sv.c:16356
#7  0x0000000000601a80 in Perl_report_uninit (uninit_sv=0xa7e840 <PL_sv_undef>) at sv.c:16390
#8  0x00000000005b50a5 in Perl_sv_2nv_flags (sv=0xa7e840 <PL_sv_undef>, flags=0) at sv.c:2645
#9  0x000000000060f407 in Perl_pp_divide () at pp.c:1627
#10 0x000000000053f5f1 in Perl_runops_debug () at dump.c:2239
#11 0x00000000004481a1 in S_run_body (oldscope=1) at perl.c:2517
#12 0x00000000004477cc in perl_run (my_perl=0xa80010) at perl.c:2440
#13 0x000000000072889a in main (argc=4, argv=0x7fffffffe618, env=0x7fffffffe640) at miniperlmain.c:122
(gdb) f 4
#4  0x00000000005fee9c in Perl_varname (gv=0xa96868, gvtype=37 '%', targ=0, keyname=0xa96bb0, aindex=0, subscript_type=3) at sv.c:15686
15686               pv_pretty(sv, SvPVX_const(keyname), SvCUR(keyname), 32, NULL, NULL,
(gdb) info locals
_svcur = 0xa96bb0
sv = 0xa963a0
name = 0xa82178
__PRETTY_FUNCTION__ = "Perl_varname"
(gdb) q



**PERL -V**

dcollins@nightshade64:~$ perl/perl  -V
Summary of my perl5 (revision 5 version 25 subversion 1) configuration:
  Commit id: 9e17953912c0ab4f21dd642345727a44c388a0af
  Platform:
    osname=linux, osvers=4.5.0-2-amd64, archname=x86_64-linux-ld
    uname='linux nightshade64 4.5.0-2-amd64 #1 smp debian 4.5.3-2 (2016-05-08) x86_64 gnulinux '
    config_args='-Dusedevel -Dprefix=/usr/local/perl-afl -Dcc=ccache afl-gcc -Duselongdouble -Duse64bitall -Doptimize=-g -Uversiononly -Uman1dir -Uman3dir -DDEBUGGING -DDEBUG_LEAKING_SCALARS -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=define
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='ccache afl-gcc', ccflags ='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion='', gccversion='6.1.0', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='long double', nvsize=16, Off_t='off_t', lseeksize=8
    alignbytes=16, prototype=define
  Linker and Libraries:
    ld='ccache afl-gcc', ldflags =' -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/local/lib/gcc/x86_64-pc-linux-gnu/6.1.0/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=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.22.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.22'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl):
  Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_COPY_ON_WRITE
                        PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
                        PERL_OP_PARENT PERL_PRESERVE_IVUV PERL_USE_DEVEL
                        USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES
                        USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_LONG_DOUBLE
                        USE_PERLIO USE_PERL_ATOF
  Built under linux
  Compiled at May 17 2016 20:01:23
  @INC:
    /usr/local/perl-afl/lib/site_perl/5.25.1/x86_64-linux-ld
    /usr/local/perl-afl/lib/site_perl/5.25.1
    /usr/local/perl-afl/lib/5.25.1/x86_64-linux-ld
    /usr/local/perl-afl/lib/5.25.1
    /usr/local/perl-afl/lib/site_perl/5.24.0
    /usr/local/perl-afl/lib/site_perl
    .


Thread Previous


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