Skip Menu |
Report information
Id: 126257
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: Invalid ARRAY attribute leads to Perl_op_lvalue_flags: Assertion `(o->op_flags & 3) != 1' failed.
Download (untitled) / with headers
text/plain 6.5k
Greetings Porters, I have compiled bleadperl with the afl-gcc compiler using: ./Configure -Dusedevel -Dprefix='/usr/local/perl-afl' -Dcc='ccache afl-gcc' -Duselongdouble -Duse64bitall -Doptimize=-g -Uversiononly -Uman1dir -Uman3dir -DDEBUGGING -DPERL_POISON -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 @@ After reducing testcases using `afl-tmin` and performing additional minimization by hand, I have located the following testcase that triggers an assert fail in the perl interpreter, but which (correctly) errors out in non-debugging perl. The simplest testcase is the 11-character file: 0/x$0my@m:d In a not-debugging perl, the output is: Invalid ARRAY attribute: d at ../uncat/f4i000005 line 1. In a debugging perl, the output is: perl: op.c:2762: Perl_op_lvalue_flags: Assertion `(o->op_flags & 3) != 1' failed. Aborted Other failing testcases that may help you understand what's going on here: 0/x$0my@m:d d\nd\nmy@G:a U(my@m:b) **GDB** dcollins@nightshade64:~/perldebug$ gdb --args ./perl -Ilib ../uncat/f4i000005 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 ./perl...done. (gdb) run Starting program: /home/dcollins/perldebug/perl -Ilib ../uncat/f4i000005 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". perl: op.c:2762: Perl_op_lvalue_flags: Assertion `(o->op_flags & 3) != 1' failed. Program received signal SIGABRT, Aborted. 0x00007ffff6cf4107 in raise () from /lib/x86_64-linux-gnu/libc.so.6 (gdb) bt #0 0x00007ffff6cf4107 in raise () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007ffff6cf54e8 in abort () from /lib/x86_64-linux-gnu/libc.so.6 #2 0x00007ffff6ced226 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #3 0x00007ffff6ced2d2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6 #4 0x000000000046c0bd in Perl_op_lvalue_flags (o=o@entry=0x120fa28, type=type@entry=185, flags=flags@entry=0) at op.c:2762 #5 0x00000000004733b7 in Perl_ck_entersub_args_list (entersubop=0x120f958) at op.c:11143 #6 Perl_ck_subr (o=0x120f958) at op.c:11732 #7 0x000000000047c2b8 in Perl_op_convert_list (type=185, flags=<optimized out>, o=0x120f958) at op.c:4598 #8 0x000000000066edbb in Perl_yyparse (gramtype=18946328) at perly.y:701 #9 0x000000000053ad55 in S_parse_body (env=env@entry=0x0, xsinit=xsinit@entry=0x42c850 <xs_init>) at perl.c:2304 #10 0x0000000000542ad3 in perl_parse (my_perl=<optimized out>, xsinit=xsinit@entry=0x42c850 <xs_init>, argc=<optimized out>, argv=<optimized out>, env=env@entry=0x0) at perl.c:1634 #11 0x000000000042c478 in main (argc=3, argv=0x7fffffffe648, env=0x7fffffffe668) at perlmain.c:114 (gdb) frame 4 #4 0x000000000046c0bd in Perl_op_lvalue_flags (o=o@entry=0x120fa28, type=type@entry=185, flags=flags@entry=0) at op.c:2762 2762 assert( (o->op_flags & OPf_WANT) != OPf_WANT_VOID ); (gdb) info locals kid = <optimized out> localize = -1 __PRETTY_FUNCTION__ = "Perl_op_lvalue_flags" (gdb) q **PERL -V** dcollins@nightshade64:~/perldebug$ ./perl -V Summary of my perl5 (revision 5 version 23 subversion 4) configuration: Commit id: 94757bf7ac8451b3588578f287f9c511a04011bf Platform: osname=linux, osvers=3.16.0-4-amd64, archname=x86_64-linux-ld uname='linux nightshade64 3.16.0-4-amd64 #1 smp debian 3.16.7-ckt11-1+deb8u4 (2015-09-19) x86_64 gnulinux ' config_args='-Dusedevel -Dprefix=/usr/local/perl-afl -Dcc=ccache afl-gcc -Duselongdouble -Duse64bitall -Doptimize=-g -Uversiononly -Uman1dir -Uman3dir -DDEBUGGING -DPERL_POISON -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='4.9.2', 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/lib/gcc/x86_64-linux-gnu/4.9/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.19.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.19' 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: DEBUGGING HAS_TIMES PERLIO_LAYERS PERL_COPY_ON_WRITE PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP 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 Oct 2 2015 22:41:42 @INC: /usr/local/perl-afl/lib/site_perl/5.23.4/x86_64-linux-ld /usr/local/perl-afl/lib/site_perl/5.23.4 /usr/local/perl-afl/lib/5.23.4/x86_64-linux-ld /usr/local/perl-afl/lib/5.23.4 .
From: Dave Mitchell <davem [...] iabyn.com>
Date: Mon, 23 Nov 2015 08:56:33 +0000
To: perl5-porters [...] perl.org
Subject: Re: [perl #126257] Invalid ARRAY attribute leads to Perl_op_lvalue_flags: Assertion `(o->op_flags & 3) != 1' failed.
Download (untitled) / with headers
text/plain 1.2k
On Sun, Oct 04, 2015 at 04:12:09AM -0700, Dan Collins wrote: Show quoted text
> 0/x$0my@m:d > > In a not-debugging perl, the output is: > Invalid ARRAY attribute: d at ../uncat/f4i000005 line 1. > > In a debugging perl, the output is: > perl: op.c:2762: Perl_op_lvalue_flags: Assertion `(o->op_flags & 3) != 1' failed. > Aborted
Now fixed with: commit 04106f2e5c6e8162bd22fd9c7505096116e483cd Author: David Mitchell <davem@iabyn.com> AuthorDate: Mon Nov 23 08:15:40 2015 +0000 Commit: David Mitchell <davem@iabyn.com> CommitDate: Mon Nov 23 08:46:48 2015 +0000 assertion failure on foo(my $x : bar) RT #126257 'my var : attr' injects a void-context sub call just after the pad op. However, Perl_ck_entersub_args_list() tries to impose lvalue context on each of its args, which causes an assertion failure. This commit makes Perl_ck_entersub_args_list() skip calling op_lvalue() on any args which are OP_ENTERSUB/OPf_WANT_VOID. Strictly speaking it should check that the sub call is actually an attribute method call (e.g. first child is a const("attibutes") etc), but this was far too much like hard work. -- No matter how many dust sheets you use, you will get paint on the carpet.


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