All wx apps crash because of nl_langinfo(CODESET) returns garbage

Corinna Vinschen
Wed Mar 1 09:19:00 GMT 2017

On Mar  1 07:56, Kolya Kosenko wrote:
> All wxWidgets-based application crash because call
> nl_langinfo(CODESET) returns sometimes garbage during wxWidgets
> initialization at
> /usr/src/debug/wxWidgets3.0-
>     char *oldLocale = strdup(setlocale(LC_CTYPE, NULL));
>     setlocale(LC_CTYPE, "");
>     const char *alang = nl_langinfo(CODESET);
>     setlocale(LC_CTYPE, oldLocale);
>     free(oldLocale);
> alang variable is not null and garbage here! It causes wxWidgets
> assertion failure at wxString::FromAscii().

At first sight this looks like a bug to me.  The information returned by
nl_langinfo is only guaranteed to be stable if you don't call setlocale
or nl_langinfo again.  If you need the result of nl_langinfo(CODESET)
even after calling setlocale again, you have to strdup it.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <>

More information about the Cygwin mailing list