[libcxx-commits] [libcxx] [libc++][windows] Use _wsetlocale() in __locale_guard (PR #160479)
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 6 04:37:09 PDT 2025
mstorsjo wrote:
> Please provide a test to ensure we don't regress on this.
Regarding a test here; I guess a test requires that the host system has a locale available with a non-ascii name. The libcxx tests does have some infrastructure for checking whether certain locales are available, for marking tests as unsupported if missing - but I'm not sure how unicode-safe that whole pipe is - from the libcxx test framework scripts, through lit up to the tests. So perhaps this would need to be a test that just unconditionally tries to set such a locale, bails out if not available. (Is there a return code we can return to mark the test as skipped, rather than succeeded? otherwise succeeded as a no-op probably is the best we can do.)
> For info, this patch has been affecting GIMP, which has been crashing on Windows when set to specific languages (e.g. Norwegian Bokmål or Turkish): https://gitlab.gnome.org/GNOME/gimp/-/issues/12626
Thanks for this context; I was wondering how this led to crashes - I thought this fault situation would only lead to the wrong locale being used. But https://developercommunity.visualstudio.com/t/setlocale-may-crash-CRT-in-some-cases/10603395 is the interesting missing clue here; `setlocale()` aborts the process when given a faulty/mangled locale name here - even though it's not supposed to.
https://github.com/llvm/llvm-project/pull/160479
More information about the libcxx-commits
mailing list