diff options
author | Alex Solovey <a.solovey@gmail.com> | 2014-05-21 16:27:14 +1000 |
---|---|---|
committer | Steffen Mueller <smueller@cpan.org> | 2014-05-28 12:34:05 +0200 |
commit | 65206418858b753c29362aa9d53c8e04a02030b5 (patch) | |
tree | fdfc4317482335914840af1811a1dbebc8729aed /AUTHORS | |
parent | 083d13e585e012fb70dca891d9820fd7ba18c89a (diff) | |
download | perl-65206418858b753c29362aa9d53c8e04a02030b5.tar.gz |
Memory leak in Storable::dclone with STORABLE_freeze hook
Storable documentation recommends using dclone shortcut in
STORABLE_freeze hook: "Unless you know better, serializing hook should
always say:
sub STORABLE_freeze {
my ($self, $cloning) = @_;
return if $cloning; # Regular default serialization
....
}
in order to keep reasonable dclone() semantics."
However, this causes a memory leak which is easy to observe with the
following small script:
=== storable-leak.plx ===
use Storable qw( dclone );
package Foo {
sub new { return bless {}, __PACKAGE__ }
sub STORABLE_freeze {
my( $self, $cloning ) = @_;
# Switch to regular default serialization results in memory leak
return if $cloning;
return 'Foo';
}
}
my $d = Foo->new();
while(1)
{
dclone( $d );
}
===
The leak is caused by missing cleanup of empty array value returned by
the hook. I've attached a simple patch for Storable-2.45 which fixes
this issue.
Reported in [perl #121928]
Amended to include version bump and Storable changelog entry.
Diffstat (limited to 'AUTHORS')
-rw-r--r-- | AUTHORS | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -54,6 +54,7 @@ Alexander Voronov <alexander-voronov@yandex.ru> Alexei Alexandrov <alexei.alexandrov@gmail.com> Alex Davies <adavies@ptc.com> Alex Gough <alex@rcon.org> +Alex Solovey <a.solovey@gmail.com> Alex Vandiver <alexmv@mit.edu> Alex Waugh <alex@alexwaugh.com> Alexander Bluhm <alexander_bluhm@genua.de> |