From: Eric Wong Date: Tue, 16 Dec 2025 10:10:25 +0000 (+0000) Subject: viewvcs: workaround leak in Perl v5.40.x series X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b57f160ab4751da60bf360a5273597d2589496d;p=thirdparty%2Fpublic-inbox.git viewvcs: workaround leak in Perl v5.40.x series 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/ --- diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index 76986f68c..2141d5e45 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -673,8 +673,12 @@ sub show ($$;$) { $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); }; }