develooper Front page | perl.perl5.porters | Postings from February 2015

Re: [perl #123738] eval {} still clobbers $@ in a DESTROY

Thread Previous | Thread Next
From:
Zefram
Date:
February 5, 2015 11:43
Subject:
Re: [perl #123738] eval {} still clobbers $@ in a DESTROY
Message ID:
20150205114304.GA21698@fysh.org
felipe@felipegasper.com wrote:
>The above code demonstrates that the change in Perl 5.14 that was intended to
>ensure that DESTROY handlers don't clobber $@ did not account for this case.

Interesting.  This is specific to the "for(Destroyer->new)" formulation;
if that's replaced with "my $x = Destroyer->new;" then $@ comes
out correctly.  The inner eval{} does not need to be an eval: "$@ =
'wibble'" works just as well to clobber $@.

It is presumably a matter of order of destruction.  The output suggests
that the localised $_ is being destroyed after the outer eval thinks
it's finished unwinding.  I don't immediately see how this happens, but
then I wouldn't, because the outer eval's idea of "finished unwinding"
is the embodiment of mine.  It was certainly my intent, in coding the
5.14 change, that code like this should see the "haha" exception in $@
immediately after the outer eval.

-zefram

Thread Previous | Thread Next


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