develooper Front page | perl.perl5.porters | Postings from January 2017

[perl #130649] Threads, shared memory, blessed objects fail to call->DESTROY method

From:
Jerry D. Hedden via RT
Date:
January 31, 2017 00:47
Subject:
[perl #130649] Threads, shared memory, blessed objects fail to call->DESTROY method
Message ID:
rt-4.0.24-31830-1485823668-1054.130649-14-0@perl.org
The bug is that the destructor of an embedded shared object will not be called after the enclosing shared object is destroyed:

1.  Create shared objects $xx and $yy.
2.  Embed $yy inside $XX:   $xx->{embedded} = $yy
3.  Undef $yy.  Its destructor is not called because it's still referenced by $xx.  (This is as expected.)
4.  Undef $xx.  The destructor for $xx is called (as expected), but the destructor for $yy is not (bug).

If the above is done with ordinary objects, the the destructors for both $xx and $yy will be called, as expected.

One workaround is to code the destructor to actively dereference any embedded objects.

The attached code illustrates both the bug and the workaround.



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