develooper Front page | perl.perl5.porters | Postings from September 2010

[perl #45091] goto in CORE::GLOBAL::exit

From:
Father Chrysostomos via RT
Date:
September 26, 2010 12:34
Subject:
[perl #45091] goto in CORE::GLOBAL::exit
Message ID:
rt-3.6.HEAD-5116-1285529655-272.45091-15-0@perl.org
On Fri Aug 31 09:11:00 2007, powerman@powerman.asdfGroup.com wrote:
> In this case 'goto' doesn't work properly, and instead of jumping to
>    the
> label, it work like 'die' and jump to the first command after 'eval':
> 
> perl -e '
> BEGIN {
>   *CORE::GLOBAL::exit = sub {
>     goto FASTCGI_NEXT_REQUEST;
>   };
> }
> while (1) {
>   eval { that_cgi_script() };
>  FASTCGI_NEXT_REQUEST:
>   last;
> }
> 
> sub that_cgi_script {
>   local $SIG{__DIE__} = sub { print "<p>error: $_[0]"; exit; print
>    "XXX\n" };
>   print "before buggy code\n";
>   eval { buggy_code() };
>   print "after buggy code\n";
> }
> sub buggy_code {
>   die "error!";
>   print "after die\n";
> }
> '
> 
> This example output:
> 
>     before buggy code
>     <p>error: error! at -e line 20.
>     after buggy code

Exiting a signal handler via goto is not supported. goto() can’t see the
label, which causes an error that is caught by the eval.
This is related to bug #44367.

If errors in signal handlers work, why not goto?




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