RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2104907 - glibc: Bad locale en_US with glibc-all-langpacks
Summary: glibc: Bad locale en_US@ampm.UTF-8 with glibc-all-langpacks
Keywords:
Status: CLOSED ERRATA
Alias: None
Deadline: 2022-08-29
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: glibc
Version: 8.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Arjun Shankar
QA Contact: Martin Coufal
Petr Hybl
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-07-07 12:54 UTC by Remi Collet
Modified: 2023-11-16 04:25 UTC (History)
11 users (show)

Fixed In Version: glibc-2.28-210.el8
Doc Type: Bug Fix
Doc Text:
.The `en_US@ampm` locale is now listed correctly by `locale -a` Previously, there was a defect in the listing of `en_US@ampm` in the output of the `locale -a` command. Consequently, the `setlocale` API failed when trying to set this locale using its name/alias printed by `locale -a`. With this update, `en_US@ampm` is now listed correctly and calls to `setlocale` succeed for all locales printed by `locale -a`.
Clone Of:
Environment:
Last Closed: 2022-11-08 10:43:12 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 2000374 0 medium CLOSED glibc: Provide English-language locale with 12-hour time 2023-07-18 14:30:35 UTC
Red Hat Issue Tracker RHELPLAN-127210 0 None None None 2022-07-07 13:01:11 UTC
Red Hat Product Errata RHBA-2022:7684 0 None None None 2022-11-08 10:43:17 UTC

Description Remi Collet 2022-07-07 12:54:48 UTC
In previous version (before 8.6)

  # locale -a | grep en_US
  en_US
  en_US.iso88591
  en_US.iso885915
  en_US.utf8


Since 8.6

  # locale -a | grep en_US
  en_US
  en_US
  en_US.iso88591
  en_US.iso885915
  en_US.utf8
  en_US.utf8

But en_US is not usable


call to setlocale(LC_ALL, "en_US.utf8") is OK
But call to setlocale(LC_ALL, "en_US") fails.


P.S. discovered as PHP test suite suddenly start failing

Comment 2 Florian Weimer 2022-07-08 07:54:18 UTC
I can reproduce this if I install glibc-all-langpacks and remove glibc-langpack-en.

Comment 3 Arjun Shankar 2022-08-18 14:55:48 UTC
This ended up being an issue with the locale definition itself, rather than all-langpacks in specific. The localedata/SUPPORTED entry (and corresponding in-dist-git-tree SUPPORTED file entry) for the en_US@ampm needs a fix-up.

Ideally, we want `locale -a' to show two @ampm locales for en_US, both using the UTF-8 charset but one mentioning it explicitly (this is in line with how `locale -a' lists other locales). We originally documented that en_US@ampm is UTF-8 when releasing the @ampm locale. From bug 2000374 doc text:

".New UTF-8 locale `en_US@ampm` with 12-hour clock

With this update, you can now use a new UTF-8 locale `en_US@ampm` with a 12-hour clock. This new locale can be combined with other locales by using the `LC_TIME` environment variable."

The entries we want are:

* en_US@ampm, using UTF-8 as an implicit default charmap
* en_US.utf8@ampm, explicitly mentioning UTF-8

A good test code fragment:

function testlocale ()
{
  if locale -a | grep -q "^${1}$"; then
    echo PASS: Locale "$1": available
  else
    echo FAIL: Locale "$1": missing
  fi
  CHRMP=$(LC_ALL="$1" locale charmap)
  if [ "$CHRMP" == "UTF-8" ]; then
    echo PASS: "$1" is UTF-8
  else
    echo FAIL: "$1" is "$CHRMP" instead of UTF-8
  fi
}
testlocale en_US.utf8@ampm
testlocale en_US@ampm

This should pass in two cases:
1. glibc-langpack-en is installed but glibc-all-langpacks is NOT installed
2. glibc-all-langpacks is installed but glibc-langpack-en is NOT installed

Of course, setting LC_TIME to the same locale names should lead to `date' showing AM/PM time instead of 24h time. Again, for both langpack RPMs separately installed.

The fix we need is:

--- a/SUPPORTED
+++ b/SUPPORTED
@@ -159,7 +159,8 @@ en_SG/ISO-8859-1 \
 en_US.UTF-8/UTF-8 \
 en_US/ISO-8859-1 \
 en_US.ISO-8859-15/ISO-8859-15 \
-en_US/UTF-8 \
+en_US@ampm/UTF-8 \
+en_US.UTF-8@ampm/UTF-8 \
 en_ZA.UTF-8/UTF-8 \
 en_ZA/ISO-8859-1 \
 en_ZM/UTF-8 \

Basically, the locale name should be in the format:
language[_territory[.codeset]][@modifier]
(https://www.gnu.org/software/libc/manual/html_node/Locale-Names.html)

Comment 4 Arjun Shankar 2022-08-24 14:31:56 UTC
With this fix, it would be good to include tests for the 'ampm' locales as well as a general sanity check for all shipped locales. I've been expanding on the test I wrote above in comment 3, and I've come up with this:

#!/bin/bash

function checklocale ()
{
  if locale -a | grep -q "^${1}$"; then
    echo PASS: Locale "$1": available
  else
    echo FAIL: Locale "$1": missing
  fi
}

function testlocale ()
{
  CHRMP=$(LC_ALL="$1" locale charmap)
  if [ "$CHRMP" == "UTF-8" ]; then
    echo PASS: "$1" is UTF-8
  else
    echo FAIL: "$1" is "$CHRMP" instead of UTF-8
  fi
  DATE=$(LC_TIME="$1" date)
  if echo $DATE | grep -q '\s[AP]M\s'; then
    echo PASS: "$1" shows AM/PM time
  else
    echo FAIL: "$1" does not show AM/PM time
  fi
}

# Make sure these two locales are definitely present
checklocale en_US.utf8@ampm
checklocale en_US@ampm

# Test *any* ampm locales found on the system for charmap and date
for l in $(locale -a | grep 'en_US.*@ampm'); do
  echo
  echo "Testing locale $l"
  testlocale $l
done

# Test *all* locales on the system for setlocale
cat > test-setlocale-with-locale-a.c <<EOF
#include <locale.h>
#include <stdio.h>

int
main (int argc, char *argv[])
{ 
  char *locale = argv[1];
  int fail = 0;

  for (int i = 0; i < 13; i++)
    if (!setlocale(i, locale))
      fail = 1;

  return fail;
}
EOF
gcc -o test-setlocale-with-locale-a test-setlocale-with-locale-a.c
for l in $(locale -a); do
  if ./test-setlocale-with-locale-a $l; then
    echo "PASS: setlocale ($l) passed"
  else
    echo "FAIL: setlocale ($l) failed"
  fi
done

And this should be tested with:
(1) glibc-langpack-en installed
(2) glibc-all-langpacks installed and *no* glibc-langpack-* packages installed at the time.

Even though the 'ampm' specific bits are RHEL-8-only, testing setlocale for all shipped locales with various common langpacks installed is a good sanity check for other/newer releases as well.

Comment 11 errata-xmlrpc 2022-11-08 10:43:12 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (glibc bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7684

Comment 14 Red Hat Bugzilla 2023-11-16 04:25:27 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days


Note You need to log in before you can comment on or make changes to this bug.