Bug 269375 - querylocale of LC_COLLATE fails after changing from C.UTF-8 to C
Summary: querylocale of LC_COLLATE fails after changing from C.UTF-8 to C
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL: https://reviews.freebsd.org/D39294
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-06 16:38 UTC by Karl Williamson
Modified: 2023-09-20 13:28 UTC (History)
1 user (show)

See Also:


Attachments
A short C reproducer program (952 bytes, text/plain)
2023-02-06 16:38 UTC, Karl Williamson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Williamson 2023-02-06 16:38:32 UTC
Created attachment 239952 [details]
A short C reproducer program

querylocale() returns C.UTF-8 for LC_COLLATE after the locale has been switched from C.UTF-8 to C.

This is likely related to #25466

Other operating systems have aliases for a given locale, but they either always have a base one that the others are synonyms for, and have querylocale always return that base locale; or they make sure to use the proper alias based on the name in the original newlocale() call.
Comment 1 Yuri Pankov freebsd_committer freebsd_triage 2023-03-28 08:23:24 UTC
What is the "#25466" that you mentioned?
Comment 2 Yuri Pankov freebsd_committer freebsd_triage 2023-03-28 14:01:44 UTC
(In reply to Yuri Pankov from comment #1)
Now I understand that you meant bug 255646, sorry for forgetting about it, and yes, seems to be the same problem!
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-03-28 15:18:38 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=269dea90d6eb32690730b0f6a17fb41170483104

commit 269dea90d6eb32690730b0f6a17fb41170483104
Author:     Yuri Pankov <yuripv@FreeBSD.org>
AuthorDate: 2023-03-28 15:10:47 +0000
Commit:     Yuri Pankov <yuripv@FreeBSD.org>
CommitDate: 2023-03-28 15:16:30 +0000

    libc: use separate collate objects for C, POSIX, and C.UTF-8

    Fix newlocale() overwriting the locale name in collate object
    when same instance was used for those locales, and querylocale()
    reporting unexpected value for LC_COLLATE_MASK.

    PR:             255646, 269375
    Reviewed by:    markj, bapt (previous version)
    Differential Revision:  https://reviews.freebsd.org/D30146

 lib/libc/locale/collate.c                    |  17 +++-
 lib/libc/tests/locale/Makefile               |   1 +
 lib/libc/tests/locale/newlocale_test.c (new) | 111 +++++++++++++++++++++++++++
 3 files changed, 126 insertions(+), 3 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-09-20 13:27:10 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a4916232acd614d4d7d7226d678b427aacb9730e

commit a4916232acd614d4d7d7226d678b427aacb9730e
Author:     Yuri Pankov <yuripv@FreeBSD.org>
AuthorDate: 2023-03-28 15:10:47 +0000
Commit:     Yuri Pankov <yuripv@FreeBSD.org>
CommitDate: 2023-09-20 13:10:52 +0000

    libc: use separate collate objects for C, POSIX, and C.UTF-8

    Fix newlocale() overwriting the locale name in collate object
    when same instance was used for those locales, and querylocale()
    reporting unexpected value for LC_COLLATE_MASK.

    PR:             255646, 269375
    Reviewed by:    markj, bapt (previous version)
    Differential Revision:  https://reviews.freebsd.org/D30146

    (cherry picked from commit 269dea90d6eb32690730b0f6a17fb41170483104)

 lib/libc/locale/collate.c                    |  17 +++-
 lib/libc/tests/locale/Makefile               |   1 +
 lib/libc/tests/locale/newlocale_test.c (new) | 111 +++++++++++++++++++++++++++
 3 files changed, 126 insertions(+), 3 deletions(-)
Comment 5 Yuri Pankov freebsd_committer freebsd_triage 2023-09-20 13:28:23 UTC
Closing as fixed, please reopen if there are still issues here.