The Perl v5.40.x series introduced a leak in some instances of
anonymous subs (aka `closures'). While Perl v5.42.0 fixes this
leak, distros like Debian 13 will use and support v5.40.x for
many more years and we won't ever encourage users to run a
non-distro Perl installation.
This fixes t/solver_git.t stalling in tests on Debian 13, but
there may be other leaks which are not currently fixed. More
work will be necessary to ensure other parts of our code don't
leak. This bug was only noticed since my coding style has
evolved towards making flow control dependent on proper memory
management (via ->DESTROY callbacks and our on_destroy helper).
I really want to eliminating anonymous subs entirely and made
another attempt towards that end. However, I haven't been able
to figure out how to preserve compatibility with various Plack
(PSGI) middlewares in current use.
Link: https://yhbt.net/mirrors/perl.git/90595091f22dad07b381fd02ff1fb7e158fd8915/s/
$l;
};
sub {
- $ctx->{-wcb} = $_[0]; # HTTP write callback
- $limiter->may_start(\&start_solver, $ctx, \&html_page);
+ # $_[0] is HTTP write callback
+ # deep copy $ctx to workaround leak in Perl 5.40.x series
+ # (v5.42.0 and <= 5.38.x are unaffected, fixed in perl.git
+ # 90595091f22dad07b381fd02ff1fb7e158fd8915:
+ my $xctx = { %$ctx, -wcb => $_[0] };
+ $limiter->may_start(\&start_solver, $xctx, \&html_page);
};
}