| Store | Cart

[perl #123287] last LABEL issues when last is called in BEGIN

From: Father Chrysostomos via RT <perl...@perl.org>
Sun, 23 Nov 2014 17:49:42 -0800
On Sun Nov 23 16:34:34 2014, exod...@gmail.com wrote:
> This issue effects multiple versions of perl, but in different ways. I have> attached a test script that demonstrates the issue.> > Here is the output in 5.20.1 and 5.10.1> > 5.20.1> >     ok 1 - outer eval 1 completed> >     ok 2 - We can escape> >     ok 3 - outer eval 2 completed> >     not ok 4 - We can escape when there is a BEGIN between us and the> > escape point> >     #   Failed test 'We can escape when there is a BEGIN between us and> > the escape point'> >     #   at test.pl line 37.> >     1..4> >     # Looks like you failed 1 test of 4.> > > 5.10.1> >     ok 1 - outer eval 1 completed> >     ok 2 - We can escape> >     ok 3 - outer eval 2 completed> >     ok 4 - We can escape when there is a BEGIN between us and the escape> > point> >     1..4> >     segmentation fault

Here is a simplified case:

$ ./perl -Ilib -e 'FOO: { eval "BEGIN { last FOO }" or die $@ }'
Label not found for "last FOO" at (eval 1) line 1.
BEGIN failed--compilation aborted at (eval 1) line 1.

$ perl5.14.4 -e 'FOO: { eval "BEGIN { last FOO }" or die $@ }'
Assertion failed: (SvTYPE(av) == SVt_PVAV), function Perl_av_len, file av.c, line 730.
Abort trap: 6

$ perl5.18.1 -e 'FOO: { eval "BEGIN { last FOO }" or die $@ }'
Can't use an undefined value as a subroutine reference.
END failed--call queue aborted at -e line 1.

Fixing this is very hard.  ‘last’ expects to be able to find the target op and return that to the runloop.  But with BEGIN we have multiple nested runloopss.  I think the only way to fix it is to use the equivalent of ‘die’ internally to get to the right runloop.  But that involves longjmping, which is something I stay away from. :-)

-- 

Father Chrysostomos


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

Recent Messages in this Thread
Chad Granum (via RT) Nov 24, 2014 12:34 am
Father Chrysostomos via RT Nov 24, 2014 01:49 am
Messages in this thread