Closed p5pRT closed 7 years ago
This issue is believed to exist in all 5.10.1+ Perl's and every older Perl as well. I have verified the issue in every Perl I have at my disposal from 5.10.1 to 5.24.0
If the last reference to an object is in thread shared memory the objects DESTROY method won't be called or highly unlikely to be called. This is a *huge* problem for applications that are OO and designed using composition of other classes (HAS-A). The last\, and possibly only reference will be in Perl's thread shared memory. I think the real issue only resembles my description and therefore it is not perfect. I have however included a small script that when used and modified as the comments suggest the related behaviors may be observed. The actual issue is a bit more unpredictable.
## PERL BUG Example
use 5.010001; use strict; use warnings; use threads; use threads::shared;
our $VERSION = 0.1;
say 'Hello World!\, - Perl shared memory failure to call ->DESTROY detector.';
LEAKER: { ## Using the "shared" attribute can play a role in this ## Best guess it means all references are shared. my $aa :shared = bless &share({})\, 'Lazy::Crazy'; my $bb :shared = bless &share({})\, 'Lazy::Crazy'; my $cc :shared = &share( bless {}\, 'Lazy::Crazy' );
## Placing an object into another makes it a sure bet its ## ->DESTROY won't be called $aa->{ has_c } = $cc; $bb->{ has_a } = $aa;
## It's strange that the order of the following assignments ## will allow the last one touched to call its ->DESTROY $cc->{ label } = 'c'; $aa->{ label } = 'a'; $bb->{ label } = 'b';
## If I'm able to control the order these are unwrapped (destroyed) ## things start working as expected. ## How likely can I always get this right\, not at all! ## (uncomment and things work as expected) # $bb = undef; # $aa = undef; # $cc = undef; }
package Lazy::Crazy;
sub DESTROY { my $self = shift; printf "# %s '%s' is destroyed\n"\, ref $self\, $self->{ label }; return; }
## END
rt.perl.org does not accept Word documents as attachments. Please re-submit in plain-text format.
Thank you very much.
-- James E Keenan (jkeenan@cpan.org)
The RT System itself - Status changed from 'new' to 'open'
@jkeenan - Status changed from 'open' to 'rejected'
Thank you for the follow-up. I did not send an attachment; however could the body of my message have been misunderstood because it was from outlook and by default in I believe html? It's a shame I can't simply edit the existing ticket's content\, if it happens to be incomplete. I think I just answered my own question; I reviewed the ticket and it does seem that the body was saved as HTML and the ticket system failed to scrap it for text.
I'll resend.
Best Regards\,
Victor Burns | TG Application Architect / Developer & Perl GURU AVP\, Consultant II System Engineer\, Bank of America T 469.201.8375 | victor.burns@bankofamerica.com 16001 N Dallas Pkwy\, Addison\, TX 75001
Like us on Facebook Follow us on Twitter
Lifeās better when weāre connectedā¢
-----Original Message----- From: James E Keenan via RT [mailto:perlbug-followup@perl.org] Sent: Thursday\, January 26\, 2017 5:57 AM To: Burns\, Victor M \victor\.burns@​bankofamerica\.com Subject: [perl #130644] Threads\, shared memory\, blessed objects fail to call ->DESTROY method
rt.perl.org does not accept Word documents as attachments. Please re-submit in plain-text format.
Thank you very much.
-- James E Keenan (jkeenan@cpan.org)
This message\, and any attachments\, is for the intended recipient(s) only\, may contain information that is privileged\, confidential and/or proprietary and subject to important terms and conditions available at http://www.bankofamerica.com/emaildisclaimer. If you are not the intended recipient\, please delete this message.
Migrated from rt.perl.org#130644 (status was 'rejected')
Searchable as RT130644$