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

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

Thread Previous
Aristotle Pagaltzis
February 6, 2015 10:16
Re: [perl #123738] eval {} still clobbers $@ in a DESTROY
Message ID:
* Aristotle Pagaltzis <> [2015-02-06 11:00]:
> So I would guess the bug is due to `foreach` aliasing – specifically
> that the per-iteration aliasing is normally undone at the end of the
> iteration but that that is preempted by the `die` here, such that the
> unaliasing winds up delayed until all the way after the statement. So
> the `warn` *inside* that statement picks up the right exception (and
> would do so even without the anti-clobber fix if my guess is right),
> but then the unaliasing catches up so that by the *next* statement the
> exception is gone.

OTOH – a `warn $_` during the same statement doesn’t see the Destroyer
instance, so the loop iterator variable is already unaliased at that
point, meaning it can’t be the unaliasing as such. But my guess is that
it still has to have to do with some aspect of how aliasing works (such
as how it interacts with the refcount, or whatever – I don’t know enough
perlguts to take a shot), since the bug is not dependent on extra scopes
(statement modifier `for` will do just fine) but does require `for` (any
regularly assigned variable will not exhibit this behaviour).

Aristotle Pagaltzis // <>

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