Skip Menu |
Report information
Id: 128189
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: dcollinsn [at] gmail.com
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)



Subject: Assert fail in sv.c with no further symptoms: e t''/$0{\0}
Download (untitled) / with headers
text/plain 7.2k
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 .
RT-Send-CC: perl5-porters [...] perl.org
The slightly shorter testcase: perl -W -e 'e f/$0{\0}/' also shows this error
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 129b
I really should finish looking through my queue before posting. Best testcase is the 8-character file: miniperl -W -e '0/$0{\0}'
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 296b
On Thu May 19 14:53:18 2016, dcollinsn@gmail.com wrote: Show quoted text
> The slightly shorter testcase: > > perl -W -e 'e f/$0{\0}/' > > also shows this error
Shorter: perl -we '"$0{\0}"' perl -we '/$0{\0}/' Any uninitialized warning that tries to mention $0{\0} will trigger it. -- Father Chrysostomos
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On Thu May 19 15:02:05 2016, sprout wrote: Show quoted text
> On Thu May 19 14:53:18 2016, dcollinsn@gmail.com wrote:
> > The slightly shorter testcase: > > > > perl -W -e 'e f/$0{\0}/' > > > > also shows this error
> > Shorter: > > perl -we '"$0{\0}"' > perl -we '/$0{\0}/' > > Any uninitialized warning that tries to mention $0{\0} will trigger it. >
It appears that the subscript has to be an OP_CONST, because qr// doesn’t trigger it. A bisect points to: commit 04698ff67968faa57a46c12d31e17c17baf08876 Author: Father Chrysostomos <sprout@cpan.org> Date: Sat Nov 27 06:22:24 2010 -0800 [perl #79178] STORE/FETCH of tie()d hash get stringified key but that is a red herring. It fixed another bug, exposing this one. Here is a similar bug with array indices. There is no crash here, but the number in the subscript is bogus: $ ./miniperl -we '"$0[\0]"' Useless use of string in void context at -e line 1. Use of reference "SCALAR(0x7fad6882fcf0)" as array index at -e line 1. Use of uninitialized value $0[1753414896] in string at -e line 1. $ perl -le 'print 0x7fad6882fcf0' 140382759484656 I would expect the output of the latter command to match the subscript in the uninit warning. -- Father Chrysostomos
To: perl5-porters [...] perl.org
Subject: Re: [perl #128189] Assert fail in sv.c with no further symptoms: e t''/$0{\0}
From: Zefram <zefram [...] fysh.org>
Date: Thu, 19 May 2016 23:33:14 +0100
Download (untitled) / with headers
text/plain 286b
Father Chrysostomos via RT wrote: Show quoted text
>Use of reference "SCALAR(0x7fad6882fcf0)" as array index at -e line 1. >Use of uninitialized value $0[1753414896] in string at -e line 1.
$ perl -le 'printf "%x\n", 1753414896' 6882fcf0 The index has been truncated to 32 bits, that's all. -zefram
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 461b
On Thu May 19 15:33:41 2016, zefram@fysh.org wrote: Show quoted text
> Father Chrysostomos via RT wrote:
> >Use of reference "SCALAR(0x7fad6882fcf0)" as array index at -e line 1. > >Use of uninitialized value $0[1753414896] in string at -e line 1.
> > $ perl -le 'printf "%x\n", 1753414896' > 6882fcf0 > > The index has been truncated to 32 bits, that's all.
I thought it might be that. I was too lazy to check. That itself is also a bug, though. -- Father Chrysostomos
From: Dave Mitchell <davem [...] iabyn.com>
Subject: Re: [perl #128189] Assert fail in sv.c with no further symptoms: e t''/$0{\0}
To: Father Chrysostomos via RT <perlbug-followup [...] perl.org>
CC: perl5-porters [...] perl.org
Date: Tue, 21 Jun 2016 15:29:03 +0100
Download (untitled) / with headers
text/plain 738b
On Thu, May 19, 2016 at 05:18:31PM -0700, Father Chrysostomos via RT wrote: Show quoted text
> On Thu May 19 15:33:41 2016, zefram@fysh.org wrote:
> > Father Chrysostomos via RT wrote:
> > >Use of reference "SCALAR(0x7fad6882fcf0)" as array index at -e line 1. > > >Use of uninitialized value $0[1753414896] in string at -e line 1.
> > > > $ perl -le 'printf "%x\n", 1753414896' > > 6882fcf0 > > > > The index has been truncated to 32 bits, that's all.
> > I thought it might be that. I was too lazy to check. That itself is also a bug, though.
The original issue is now fixed with v5.25.2-15-g55b6481. I'm not going to address the 32-bitness of the AV API here. -- Dave's first rule of Opera: If something needs saying, say it: don't warble it.
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 297b
On Tue Jun 21 07:29:25 2016, davem wrote: Show quoted text
> I'm not going to address the 32-bitness of the AV API here.
The AV API was changed to support 64-bit indices some time ago (e.g. v5.19.3-99-gc70927a), but report_uninit_var got left behind. I have fixed it in commit 1b3df0e. -- Father Chrysostomos


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org