Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid ARRAY attribute leads to Perl_op_lvalue_flags: Assertion `(o->op_flags & 3) != 1' failed. #14962

Closed
p5pRT opened this issue Oct 4, 2015 · 4 comments
Labels

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Oct 4, 2015

Migrated from rt.perl.org#126257 (status was 'resolved')

Searchable as RT126257$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Oct 4, 2015

From @dcollinsn

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​: 94757bf
  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
  .

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 23, 2015

From @iabyn

On Sun, Oct 04, 2015 at 04​:12​:09AM -0700, Dan Collins wrote​:

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 04106f2
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.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 23, 2015

The RT System itself - Status changed from 'new' to 'open'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Nov 23, 2015

@iabyn - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this Nov 23, 2015
@p5pRT p5pRT added the Severity Low label Oct 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.