-
Notifications
You must be signed in to change notification settings - Fork 594
Closed
Labels
Description
Description
Starting in v5.40, some closures leak memory despite there being no reference cycles.
Steps to Reproduce
#!/usr/bin/env perl
use v5.38;
use Scalar::Util qw(weaken);
my $wref;
{
my $x;
my $subject = sub {
$x = $_[0];
my $y;
return sub { $y };
};
my $subscriber = {};
weaken($wref = $subscriber);
$subscriber->{foo} = $subject->($subscriber);
}
!defined $wref or die "Leak";
$ perl bleak.pl
Leak at bleak.pl line 18.
$
This used to work in v5.38. It is broken in v5.40 and blead.
Expected behavior
$ perl bleak.pl
$