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

Can't use &exit from END block in Rakudo, all backends #3435

Closed
p6rt opened this issue Jul 21, 2014 · 6 comments
Closed

Can't use &exit from END block in Rakudo, all backends #3435

p6rt opened this issue Jul 21, 2014 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Jul 21, 2014

Migrated from rt.perl.org#122355 (status was 'resolved')

Searchable as RT122355$

@p6rt
Copy link
Author

p6rt commented Jul 21, 2014

From @masak

<hoelzro> in Perl 5, one can assign to $? in an END block to alter a
program's exit status. Is there an analogous construct in Perl 6?
<masak> hoelzro​: `exit($status);`
<masak> hm, `END exit(5)` hangs locally.
<hoelzro> masak​: that's what I tried, and also discovered =)
<masak> r​: END exit(5)
<camelia> rakudo-{parrot,moar} e56d94​: OUTPUT«(timeout)»
<camelia> ..rakudo-jvm e56d94​: OUTPUT«(timeout)Unhandled exception​:
java.lang.StackOverflowError [...]
* masak submits rakudobug

Moar and Parrot loop forever; the JVM blows the call stack. My guess
is that a call to &exit tries to run all the registered END blocks or
something.

I don't recall the spec mentioning this, but it feels fairly obvious
to me that we should support calling &exit from an END block, and that
it should Just Work. We probably should have wording in S32 to that
effect.

@p6rt
Copy link
Author

p6rt commented Jul 21, 2014

From @lizmat

On 21 Jul 2014, at 09​:25, Carl Mäsak (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by "Carl Mäsak"
# Please include the string​: [perl #​122355]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=122355 >

<hoelzro> in Perl 5, one can assign to $? in an END block to alter a
program's exit status. Is there an analogous construct in Perl 6?
<masak> hoelzro​: `exit($status);`
<masak> hm, `END exit(5)` hangs locally.
<hoelzro> masak​: that's what I tried, and also discovered =)
<masak> r​: END exit(5)
<camelia> rakudo-{parrot,moar} e56d94​: OUTPUT«(timeout)»
<camelia> ..rakudo-jvm e56d94​: OUTPUT«(timeout)Unhandled exception​:
java.lang.StackOverflowError [...]
* masak submits rakudobug

Moar and Parrot loop forever; the JVM blows the call stack. My guess
is that a call to &exit tries to run all the registered END blocks or
something.

I don't recall the spec mentioning this, but it feels fairly obvious
to me that we should support calling &exit from an END block, and that
it should Just Work. We probably should have wording in S32 to that
effect.

FWIW, I think the problem is that running the END blocks does not remove them from the list of END blocks.

Each END block should only be run *once*. Hence, execution of an END block should remove it from the list *before* executing it.

Pretty sure that would solve this problem.

Liz

@p6rt
Copy link
Author

p6rt commented Jul 21, 2014

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

@p6rt
Copy link
Author

p6rt commented Oct 21, 2014

From @usev6

This seems to work now​:

$ perl6-m -e 'END exit(5)'; echo $?
5
$ perl6-p -e 'END exit(5)'; echo $?
5
$ perl6-j -e 'END exit(5)'; echo $?
5

I added a test to S04-phasers/end.t with the following commit​: Raku/roast@7050e78bc7

I'm closing the ticket now.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 21, 2014

From @usev6

This seems to work now​:

$ perl6-m -e 'END exit(5)'; echo $?
5
$ perl6-p -e 'END exit(5)'; echo $?
5
$ perl6-j -e 'END exit(5)'; echo $?
5

I added a test to S04-phasers/end.t with the following commit​: Raku/roast@7050e78bc7

I'm closing the ticket now.

@p6rt
Copy link
Author

p6rt commented Oct 21, 2014

@usev6 - Status changed from 'open' to 'resolved'

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

No branches or pull requests

1 participant