From: Corinna Vinschen <vinschen@redhat.com>
To: Koichi MURASE <myoga.murase@gmail.com>
Cc: newlib@sourceware.org
Subject: Re: [PATCH, newlib/libc/locale] Fix broken '_duplocale_r' which called '__loadlocale' in an incorrect way
Date: Mon, 13 Mar 2017 10:13:00 -0000 [thread overview]
Message-ID: <20170313101339.GH3340@calimero.vinschen.de> (raw)
In-Reply-To: <CAFLRLk9RALcRRy6B=rBRXMD-yoXMiC0_NoRjJb98FWoOsYOzkg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1956 bytes --]
On Mar 12 01:50, Koichi MURASE wrote:
> Hello, I send a patch here.
>
> Problem:
>
> After passing locales created by 'duplocale' to 'uselocale',
> referencing 'MB_CUR_MAX', which is actually expanded to
> '__locale_mb_cur_max()' by preprocessors, causes segmentation faults.
> Direct use of locales from 'newlocale' does not cause the problem.
> This is the problem of 'duplocale'.
> [...]
> Bug:
>
> In the beginning of '__loadlocale' (newlib/libc/locale/locale.c:501),
> there is a code which checks if the operations can be skipped:
>
> > /* Avoid doing everything twice if nothing has changed. */
> > if (!strcmp (new_locale, loc->categories[category]))
> > return loc->categories[category];
>
> While, in the function '_duplocale_r' (newlib/libc/locale/
> duplocale.c), '__loadlocale' is called as in the quoted codes:
>
> > /* If the object is not a "C" locale category, copy it. Just call
> > __loadlocale. It knows what to do to replicate the category. */
> > tmp_locale.lc_cat[i].ptr = NULL;
> > tmp_locale.lc_cat[i].buf = NULL;
> > if (!__loadlocale (&tmp_locale, i, tmp_locale.categories[i]))
> > goto error;
>
> This call of '__loadlocale' results in the skip check being
>
> !strcmp(tmp_locale.categories[i], tmp_locale.categories[i]),
>
> which is always true. This means that the actual operations of
> '__loadLocale' will never be performed for 'duplocale'.
>
> Fix:
>
> The call of '__loadlocale' in '_duplocale_r' is modified.
>
> Please see the attached file for the fix as tabs in the mail body
> seem to be converted to spaces by Gmail.
>
> Best regards,
> Koichi Murase
Thanks for tracking this down and fixing. I applied your patch with
just a bit of code commenting added.
Thanks again,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
prev parent reply other threads:[~2017-03-13 10:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-11 16:50 Koichi MURASE
2017-03-13 10:13 ` Corinna Vinschen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170313101339.GH3340@calimero.vinschen.de \
--to=vinschen@redhat.com \
--cc=myoga.murase@gmail.com \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).