This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Gracefully handle incompatible locale data
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Ludovic CourtÃs <ludo at gnu dot org>
- Cc: OndÅej BÃlka <neleai at seznam dot cz>, libc-alpha at sourceware dot org, guix-devel at gnu dot org, Roland McGrath <roland at hack dot frob dot com>
- Date: Wed, 28 Oct 2015 01:38:57 -0400
- Subject: Re: [PATCH] Gracefully handle incompatible locale data
- Authentication-results: sourceware.org; auth=none
- References: <876132lbic dot fsf at gnu dot org> <20150922191804 dot GA13637 at domone> <877fnijgin dot fsf at gnu dot org> <20150922215022 dot GA27201 at domone> <8737y4hkrz dot fsf at gnu dot org> <20150924082755 dot GA4767 at domone> <87h9mjeqyy dot fsf at gnu dot org> <5605BA8D dot 40907 at redhat dot com> <87h9mh5vgn dot fsf at gnu dot org> <5609A8E9 dot 7050201 at redhat dot com> <87io6t1wbu dot fsf at gnu dot org> <561D078A dot 5080307 at redhat dot com> <87si5en7y9 dot fsf at gnu dot org>
On 10/13/2015 10:45 AM, Ludovic CourtÃs wrote:
>> - What does localedef --list-archive return?
>>
>> - The new LC_COLLATE format will make it's way into the binary locale archive
>> and that means glibc can't read the locale-archive? Does it fail? exit code?
>
> The patch does not change how locale archives are handled.
>
> I think weâre confusing locale archive and locale data; or am I simply
> missing something? :-)
Your patch is OK.
Notes:
(1) Do we return NULL and EINVAL? Yes.
Loading locale data from the locale archive uses _nl_load_locale_from_archive.
The function _nl_load_locale_from_archive calls _nl_intern_locale_data
which can trigger the assert on invalid type sizes.
~~~ locale/loadarchive.c ~~~
134 _nl_load_locale_from_archive (int category, const char **namep)
...
478 lia->data[cnt] = _nl_intern_locale_data (cnt,
479 results[cnt].addr,
480 results[cnt].len);
~~~
Which seems like it can trigger the assertion when loading the larger
LC_COLLATE data from the archive. Now we return NULL, ignore the failed load,
and potentially return NULL again since `lia->data[category]` is now NULL.
This means `_nl_find_locale` returns NULL, and then functions like `setlocale`
appear to return NULL to indicate no data was loaded with errno set to EINVAL.
(2) Does localedef --list-archive work?
Yes. It is unaffected by the LC_COLLATE changes since the locale archive records
have explicit length and can be listed even when they can't be loaded. This is
wrong IMO, and we should have done something to detect the invalid LC_COLLATE
and print a warning, but that's another QoI issue unrelated to the patch you're
trying to apply.
c.