develooper Front page | perl.perl5.porters | Postings from February 2015

[perl #123712] Segmentation fault in S_scan_heredoc()

Thread Previous
From:
Father Chrysostomos via RT
Date:
February 16, 2015 01:39
Subject:
[perl #123712] Segmentation fault in S_scan_heredoc()
Message ID:
rt-4.0.18-5680-1424050758-1880.123712-15-0@perl.org
On Tue Feb 10 12:38:15 2015, sprout wrote:
> On Tue Feb 10 10:15:07 2015, hv wrote:
> > On Sun Feb 01 14:41:10 2015, sprout wrote:
> > > On Sun Feb 01 14:38:39 2015, sprout wrote:
> >
> > > > This is likely related to #123617, though it appears to be more
> > > > recent.  I’m running a bisect.
> > >
> > > 4efe39d21e072e88e12e308ed1f068461f8ef778 is the first bad commit
> > > commit 4efe39d21e072e88e12e308ed1f068461f8ef778
> > > Author: Father Chrysostomos <sprout@cpan.org>
> > > Date:   Wed Aug 29 22:07:18 2012 -0700
> > >
> > > toke.c:scan_heredoc: Merge similar code
> > >
> > > The code for looking in outer lexing scopes was mostly identical to
> > > the code for looking in PL_linestr.
> >
> > The below is one aspect changed from the original, and is enough to
> > make it survive (and pass tests); I'm not sure why reality doesn't
> > match the various comments though (so that we're here with !infile
> > and
> > !PL_lex_inwhat, and it isn't an eval, and doesn't have a newline), so
> > I'm not sure how to fix those.
> 
> A call to skipspace that happens inside /$a[/ tries to read the next
> line of the file.  When EOF is reached PL_rsfp is set to NULL, which
> is why S_scan_heredoc thinks we are inside an eval, which is not the
> case.
> 
> A similar circumstance can arise with:
> 
> perl -e 'print q|/$a[<<end]/+<<| . "\nend"'|./miniperl
> 
> which does indeed make S_scan_heredoc think it is in an eval, but the
> first line does end with \n, so the memchr returns something and the
> assertion does not fail.
> 
> scan_heredoc’s assumptions are reasonable.  I think we need to fix
> that /$a[/ bug, which will unfortunately break my japhs. :-(

I have finally fixed this in e47d32d.  What I said about skipspace was not correct.  skipspace was doing the right thing, but many other paths were calling lex_read_space or lex_next_chunk without the proper guards.  But putting guards all over the place seemed the wrong approach, so I modified lex_next_chunk instead.

-- 

Father Chrysostomos


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

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