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

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

Thread Previous | Thread Next
February 5, 2015 11:43
Re: [perl #123738] eval {} still clobbers $@ in a DESTROY
Message ID: 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.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About