develooper Front page | perl.perl5.porters | Postings from January 2017

Re: [perl #126191] null ptr deref and segfault: Perl_pad_add_anon(pad.c:821) [perl 5.21.7]

Thread Next
From:
Zefram
Date:
January 27, 2017 08:07
Subject:
Re: [perl #126191] null ptr deref and segfault: Perl_pad_add_anon(pad.c:821) [perl 5.21.7]
Message ID:
20170127080658.GE6507@fysh.org
This bug is very sensitive to the details of the syntax errors.  In the
execution that leads up to the assertion failure, the second sub{} is
treated as being nested inside the first, and this is crucial to the
failure mode.  (Almost any edit to the test code leads to them being
treated as sequential, avoiding the assertion failure.)

The first newANONATTRSUB() call, for the second sub{}, succeeds.
The second newANONATTRSUB() call, for the first sub{}, then fails,
because it finds that PL_compcv is null.  PL_compcv becomes null as a
side effect of the first newANONATTRSUB() call, and in normal operation
the value that PL_compcv had in the surrounding scope would immediately be
restored, with the end of compilation of the nested sub{}.  Evidently the
restoration isn't happening.  This is obviously for reasons tied up with
the parser's error recovery, a pretty opaque part of the code.

-zefram

Thread Next


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