fix: prefer suffixed locales to avoid Perl 5.42.0 panic (GH #448)#450
Draft
toddr-bot wants to merge 1 commit into
Draft
fix: prefer suffixed locales to avoid Perl 5.42.0 panic (GH #448)#450toddr-bot wants to merge 1 commit into
toddr-bot wants to merge 1 commit into
Conversation
Perl 5.42.0 panics when nl_langinfo(CODESET) returns empty for a locale that setlocale() accepted. On macOS, bare locale names like 'en_GB' trigger this because they lack a codeset suffix. Fix by trying suffixed locales (.UTF-8, etc.) before bare names in the locale probe loop. Also reorder @LOCALE_SUFFIX to try .UTF-8 first since it is the most common modern encoding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Prefer suffixed locale names (e.g.
en_GB.UTF-8) over bare names (e.g.en_GB) when probing locale availability in Template::Plugin::Date.Why
Perl 5.42.0 introduced a fatal panic in
locale.cwhennl_langinfo(CODESET)returns empty for a locale thatsetlocale()accepted. On macOS, bare locale names likeen_GBlack a codeset, sosetlocale(LC_ALL, "en_GB")succeeds but subsequentstrftime()panics because Perl internally queries the codeset.Reproducer (no Template modules needed):
See #448 for full analysis.
How
Two changes to the locale probe loop in
Date.pm:Try suffixed locales first, bare last:
for my $suffix (@LOCALE_SUFFIX, '')instead of('', @LOCALE_SUFFIX). On macOS,en_GB.UTF-8matches before the bareen_GB, avoiding the panic.Reorder @LOCALE_SUFFIX:
.UTF-8moved to front since it's the most common modern encoding. Previous order was.ISO8859-1first (historical).Both changes are backwards compatible — if only bare locale names exist on a system, the fallback at the end of the loop still finds them.
The mirror loop in
t/date.tis updated to match.Testing
t/date.tpassesmake test)Closes #448
Quality Report
Changes: 2 files changed, 3 insertions(+), 3 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan