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

last LABEL issues when last is called in BEGIN #14270

Open
p5pRT opened this issue Nov 24, 2014 · 4 comments
Open

last LABEL issues when last is called in BEGIN #14270

p5pRT opened this issue Nov 24, 2014 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 24, 2014

Migrated from rt.perl.org#123287 (status was 'open')

Searchable as RT123287$

@p5pRT
Copy link
Author

p5pRT commented Nov 24, 2014

From @exodist

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

@p5pRT
Copy link
Author

p5pRT commented Nov 24, 2014

From @exodist

test.pl

@p5pRT
Copy link
Author

p5pRT commented Nov 24, 2014

From @cpansprout

On Sun Nov 23 16​:34​:34 2014, exodist7@​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

@p5pRT
Copy link
Author

p5pRT commented Nov 24, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants