Created
May 30, 2015 03:17
-
-
Save exodist/5a4488599967dfa87a6d to your computer and use it in GitHub Desktop.
This is broken on perls < 5.20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
sub do_it(&) { | |
my $sub = shift; | |
my $finished = 0; | |
my ($ok, $err); | |
FOO: { | |
my $ok = eval { $sub->(); 1 }; | |
$err = $@; | |
if ($ok) { | |
$finished++; | |
} | |
elsif($err =~ m/Label not found for "last FOO"/) { | |
$ok = 1; | |
$err = undef; | |
} | |
die $err unless $ok; | |
} | |
return $finished; | |
} | |
# Uncomment one or all of the following. | |
# The first one has no problems | |
# The second and third causes segfaults | |
# In the code where I found this issue, example 2 would get 'not a CODE reference' before the segv | |
# In the code where I found this issue, example 3 could say 'Size magic not implemented.' before the segv | |
# In this example, the error at the end of example 3 is very interesting! | |
# In all examples the final line "Got to the end!" prints fine. | |
# Strangely adding 'exit 0' to the end of this file fixes everything! | |
#do_it { | |
# no warnings 'exiting'; | |
# last FOO; | |
#}; | |
#do_it { | |
# no warnings 'exiting'; | |
# eval "BEGIN { last FOO }; 1" || die $@; | |
#}; | |
#do_it { | |
# require File::Temp; | |
# my ($fh, $name) = File::Temp::tempfile(); | |
# print $fh "no warnings 'exiting';\nBEGIN { last FOO }\n1;\n"; | |
# close($fh); | |
# do $name; | |
# die $@ if $@; | |
#}; | |
print "Got to the end!\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment