Problem
The memory leak tests t/zz-grammar-factory-leak.t and t/zz-process-leak.t fail on CPAN testers running with AUTOMATED_TESTING=1 and Test::LeakTrace installed.
Affected reports (3.106):
Both reports show identical failures:
| Test file |
Failed |
Total |
Details |
t/zz-grammar-factory-leak.t |
4 |
8 |
tests 3-6 (all no_leaks_ok calls) |
t/zz-process-leak.t |
3 |
6 |
tests 1, 3, 5 (all no_leaks_ok calls) |
Details
Every no_leaks_ok block detects 3 leaked SVs per Template->new() + process() cycle. The leak diagnostic output identifies leaked SVs originating from:
Template::Grammar->new() (Parser.pm:179) — Grammar singleton re-creation
$CONTEXT->new($params) (Config.pm:234) — Context object allocation
split(/$dlim/, $path) (Provider.pm:340) — REGEXP SV from INCLUDE_PATH delimiter
The factory cleanup fix from PR #344 (commit 6f8ba8c) added reference-counting to the Grammar $factory singleton. However, this causes the factory to be freed and re-allocated on each Template lifecycle rather than remaining a persistent singleton, which means Test::LeakTrace sees new allocations on every cycle. The other two leak sources (Config, Provider) were not addressed by PR #344.
Why most PASS reports don't catch this
Both tests are gated behind AUTOMATED_TESTING || RELEASE_TESTING and require Test::LeakTrace to be installed. Most CPAN testers in the PASS matrix likely skip these tests entirely. The failing testers (ANDK, BINGOS) are known automated smoke testers who set AUTOMATED_TESTING=1 and have Test::LeakTrace available.
Possible fixes
- Fix the underlying leaks — Track down why 3 SVs survive each Template processing cycle and ensure proper cleanup. The
$factory reference-counting logic in Grammar.pm may need to avoid freeing the singleton so it remains a one-time allocation.
- Guard with
--dev flag — If the leaks are known/acceptable, gate these tests behind $ENV{AUTHOR_TESTING} or $ENV{RELEASE_TESTING} only (remove AUTOMATED_TESTING) so they don't cause FAIL reports from automated smokers.
- Use
leaks_cmp_ok with a tolerance — Replace no_leaks_ok with leaks_cmp_ok { ... } '<=', 3 to allow the known singleton allocation while still catching regressions.
🤖 Created by Kōan from CPAN tester failure analysis
Problem
The memory leak tests
t/zz-grammar-factory-leak.tandt/zz-process-leak.tfail on CPAN testers running withAUTOMATED_TESTING=1andTest::LeakTraceinstalled.Affected reports (3.106):
Both reports show identical failures:
t/zz-grammar-factory-leak.tno_leaks_okcalls)t/zz-process-leak.tno_leaks_okcalls)Details
Every
no_leaks_okblock detects 3 leaked SVs perTemplate->new()+process()cycle. The leak diagnostic output identifies leaked SVs originating from:Template::Grammar->new()(Parser.pm:179) — Grammar singleton re-creation$CONTEXT->new($params)(Config.pm:234) — Context object allocationsplit(/$dlim/, $path)(Provider.pm:340) — REGEXP SV from INCLUDE_PATH delimiterThe factory cleanup fix from PR #344 (commit 6f8ba8c) added reference-counting to the Grammar
$factorysingleton. However, this causes the factory to be freed and re-allocated on each Template lifecycle rather than remaining a persistent singleton, which meansTest::LeakTracesees new allocations on every cycle. The other two leak sources (Config, Provider) were not addressed by PR #344.Why most PASS reports don't catch this
Both tests are gated behind
AUTOMATED_TESTING || RELEASE_TESTINGand requireTest::LeakTraceto be installed. Most CPAN testers in the PASS matrix likely skip these tests entirely. The failing testers (ANDK, BINGOS) are known automated smoke testers who setAUTOMATED_TESTING=1and haveTest::LeakTraceavailable.Possible fixes
$factoryreference-counting logic in Grammar.pm may need to avoid freeing the singleton so it remains a one-time allocation.--devflag — If the leaks are known/acceptable, gate these tests behind$ENV{AUTHOR_TESTING}or$ENV{RELEASE_TESTING}only (removeAUTOMATED_TESTING) so they don't cause FAIL reports from automated smokers.leaks_cmp_okwith a tolerance — Replaceno_leaks_okwithleaks_cmp_ok { ... } '<=', 3to allow the known singleton allocation while still catching regressions.🤖 Created by Kōan from CPAN tester failure analysis