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

[perl #129826] Invalid read of size 8 in S_parse_body (perl.c:2166)when argv ends with --

Thread Previous
From:
Tony Cook via RT
Date:
October 26, 2016 00:20
Subject:
[perl #129826] Invalid read of size 8 in S_parse_body (perl.c:2166)when argv ends with --
Message ID:
rt-4.0.24-32720-1477441200-1389.129826-15-0@perl.org
On Fri Oct 07 07:35:10 2016, nine@detonation.org wrote:
> When perl is run with a command line that ends in "--" as in:
> perl -e 0 --
> S_parse_body will do an invalid memory access trying to set
> scriptname to argv[0] which by then points after the -- and thus
> outside the original arguments list.
> 
> Noticed by valgrinding Inline::Perl5 which embeds perl in Perl 6.
> I failed to reproduce the valgrind output with just running perl
> because probably valgrind thinks the -- is part of its own command
> line.

I haven't been able to reproduce this.

I tried:

- a default + -DDEBUGGING build of blead (system gcc, 4.9.2)

- a default + -DDEBUGGING build of 5.24.0 (system gcc)

- a build of 5.24.0 with your switches. (system gcc)

- a build of 5.24.0 with your switches. (gcc 5.2.0)

Could you please provide a backtrace of the failure?

I also checked whether valgrind is passing the -- through, first I started
valgrind with debugging enabled:

  $ LD_LIBRARY_PATH=. valgrind --vgdb=full --vgdb-stop-at=startup ./perl -e 0 --
  ...
  ==16307==   target remote | /usr/lib/valgrind/../../bin/vgdb --pid=16307
  ...

Then connected to it with the debugger
  $ gdb ./perl
  ...
  (gdb) target remote | /usr/lib/valgrind/../../bin/vgdb --pid=16307
  Remote debugging using | /usr/lib/valgrind/../../bin/vgdb --pid=16307
  ...
  (gdb) b main
  Breakpoint 1 at 0x400d50: file perlmain.c, line 62.
  (gdb) c
  Continuing.
  
  Breakpoint 1, main (argc=4, argv=0xfff0007b8, env=0xfff0007e0) at perlmain.c:62
  62      {
  (gdb) p argv[0]
  $1 = 0xfff000a73 "./perl"
  (gdb) p argv[1]
  $2 = 0xfff000a7a "-e"
  (gdb) p argv[2]
  $3 = 0xfff000a7d "0"
  (gdb) p argv[3]
  $4 = 0xfff000a7f "--"
  (gdb) c
  Continuing.
  [Inferior 1 (Remote target) exited normally]
  (gdb) 

and valgrind finished with no errors:

  ==16307== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=129826

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