Summary
t/date.t fails with SIGABRT on Perl 5.42.0 (Darwin/macOS) when locale-aware date formatting is exercised. The process panics inside Perl's internal locale.c when nl_langinfo(CODESET) returns an empty string for the en_GB locale.
CPAN Testers Report
Error
Template process failed: undef error - locale.c: 6632: panic: nl_langinfo returned empty
for 0 in supposed locale 'en_GB'; which really is 'en_GB'
codeset is ''; radix='.'; January='January'; strtod(1,5)=1, strtod(1.5)=1.5
The panic occurs at the first locale-using test (test block 8 in t/date.t):
[% USE english = date(format => '%A', locale => 'en_GB') %]
[% english.format %]
The call chain is: Template::Plugin::Date::format() → POSIX::setlocale(LC_ALL, 'en_GB') → _strftime() → Perl's internal locale.c panics because nl_langinfo(CODESET) returns empty for the en_GB locale on this macOS system.
Impact
- 22 of 39 subtests reported as failed
- Process killed by SIGABRT (Wstat: 6, Signal: ABRT) after test 19
- "Bad plan. You planned 39 tests but ran 19" — the abort killed the process mid-run
- Only 1 of 121 test programs failed; all 3278 other subtests passed
Analysis
This appears to be a Perl 5.42.0 core issue, not a Template Toolkit bug. The setlocale(LC_ALL, 'en_GB') call succeeds (returns 'en_GB'), but Perl's internal locale validation in locale.c then panics when nl_langinfo returns an empty codeset. This is new behavior in Perl 5.42.0 — the same locale handling works on earlier Perl versions.
The en_GB locale on macOS (without a codeset suffix like .UTF-8) may legitimately have an empty codeset from nl_langinfo, but previous Perl versions did not treat this as a fatal condition.
Possible Mitigations
Template Toolkit could work around this by:
-
Appending .UTF-8 to locale names that lack a codeset suffix — the plugin already tries suffixes like .ISO8859-1 and .UTF-8 in @LOCALE_SUFFIX, but the bare en_GB matches first (since setlocale accepts it) and the suffix loop stops. The logic at lib/Template/Plugin/Date.pm:167-176 could be changed to prefer a locale with a codeset suffix when available.
-
Using LC_TIME instead of LC_ALL — the plugin only needs time/date formatting, so setlocale(LC_TIME, ...) would be more targeted and might avoid triggering the nl_langinfo(CODESET) check.
-
Wrapping the strftime call in eval — catch the panic before it kills the process (though SIGABRT from locale.c may not be catchable).
However, this should also be reported upstream to Perl — panicking on a locale that setlocale() itself accepted is arguably a Perl bug.
🤖 Created by Kōan from CPAN Testers analysis
Summary
t/date.tfails with SIGABRT on Perl 5.42.0 (Darwin/macOS) when locale-aware date formatting is exercised. The process panics inside Perl's internallocale.cwhennl_langinfo(CODESET)returns an empty string for theen_GBlocale.CPAN Testers Report
Error
The panic occurs at the first locale-using test (test block 8 in
t/date.t):The call chain is:
Template::Plugin::Date::format()→POSIX::setlocale(LC_ALL, 'en_GB')→_strftime()→ Perl's internallocale.cpanics becausenl_langinfo(CODESET)returns empty for theen_GBlocale on this macOS system.Impact
Analysis
This appears to be a Perl 5.42.0 core issue, not a Template Toolkit bug. The
setlocale(LC_ALL, 'en_GB')call succeeds (returns'en_GB'), but Perl's internal locale validation inlocale.cthen panics whennl_langinforeturns an empty codeset. This is new behavior in Perl 5.42.0 — the same locale handling works on earlier Perl versions.The
en_GBlocale on macOS (without a codeset suffix like.UTF-8) may legitimately have an empty codeset fromnl_langinfo, but previous Perl versions did not treat this as a fatal condition.Possible Mitigations
Template Toolkit could work around this by:
Appending
.UTF-8to locale names that lack a codeset suffix — the plugin already tries suffixes like.ISO8859-1and.UTF-8in@LOCALE_SUFFIX, but the bareen_GBmatches first (sincesetlocaleaccepts it) and the suffix loop stops. The logic atlib/Template/Plugin/Date.pm:167-176could be changed to prefer a locale with a codeset suffix when available.Using
LC_TIMEinstead ofLC_ALL— the plugin only needs time/date formatting, sosetlocale(LC_TIME, ...)would be more targeted and might avoid triggering thenl_langinfo(CODESET)check.Wrapping the strftime call in eval — catch the panic before it kills the process (though SIGABRT from locale.c may not be catchable).
However, this should also be reported upstream to Perl — panicking on a locale that
setlocale()itself accepted is arguably a Perl bug.🤖 Created by Kōan from CPAN Testers analysis