Skip to content

locale.c: Don't ever use system LC_ALL #20241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2022
Merged

Conversation

khwilliamson
Copy link
Contributor

@khwilliamson khwilliamson commented Sep 3, 2022

This fixes #20231

LC_ALL is a compendium of the individual locale categories, such as
LC_CTYPE, LC_NUMERIC, .... When all categories are in the same locale,
it acts just like an individual category. But when the categories are
not in the same locale, some means must be used to indicate that.
Platforms differ in how they represent this. Alpine uses:

a;b;c;d;e;f

where 'a' is the locale for the category that Alpine has decided is associated with the first position; 'b', the locale for the second position category, and so on. (I don't know what the details are for Alpine). Other platforms separate by a '/' (and may have a different deterministic ordering). And glibc uses a more informative format:

LC_CTYPE=a;LC_NUMBERIC=b; ...

This has the advantage that it's obvious to the reader what is what, and
the order in the string is irrelevant.

It might be possible, but painful, for a Configure probe to figure out
what the syntax is for the current platform. I chose not to do that. A
platform might come along with a novel syntax unanticipated by whatever
probe we came up with.

Instead, perl uses the glibc format internally, and when it needs to get
or set LC_ALL from the system, it loops through each category
individually, so that by the time it has done all of them, LC_ALL will
have been implicitly handled.

The breaking commit a7ff7ac failed to do that.

This fixes Perl#20231

LC_ALL is a compendium of the individual locale categories, such as
LC_CTYPE, LC_NUMERIC, ....  When all categories are in the same locale,
it acts just like an individual category.  But when the categories are
not in the same locale, some means must be used to indicate that.
Platforms differ in how they represent this.  Alpine uses:

    a;b;c;d;e;f

where each letter is replaced by the correct locale for a given
category.  Which category is in which position is deterministic, and
platform-specific.  Other platforms separate by a '/'.  And glibc uses a
more informative format:

    LC_CTYPE=a;LC_NUMBERIC=b; ...

This has the advantage that it's obvious to the reader what is what, and
the order in the string is irrelevant.

It might be possible, but painful, for a Configure probe to figure out
what the syntax is for the current platform.  I chose not to do that.  A
platform might come along with a novel syntax unanticipated by whatever
probe we came up with.

Instead, perl uses the glibc format internally, and when it needs to get
or set LC_ALL from the system, it loops through each category
individually, so that by the time it has done all of them, LC_ALL will
have been implicitly handled.

The breaking commit a7ff7ac failed to do that.
@bram-perl
Copy link

Testing on Alpine, with -Duseithreads

All tests successful.
Files=2720, Tests=1186579, 1530 wallclock secs (114.92 usr 10.63 sys + 943.20 cusr 100.14 csys = 1168.89 CPU)
Result: PASS

@khwilliamson khwilliamson merged commit ec18fac into Perl:blead Sep 7, 2022
@khwilliamson khwilliamson deleted the alpine branch September 7, 2022 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple Test Failures on Alpine Linux with Threads Enabled
3 participants