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.
