www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/08/11/19:40:26

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 179543858C52
Authentication-Results: sourceware.org;
dmarc=fail (p=none dis=none) header.from=nifty.ne.jp
Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp
DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com 27BNcsv1014550
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp;
s=dec2015msa; t=1660261135;
bh=GtuWTVG36ILb5ZYredWz36oTL+NbcMOKmtOGpoDeC78=;
h=Date:From:To:Subject:In-Reply-To:References:From;
b=TtsKQUfyRArIwm9IoDUTiD3udFTj07r5NBWKUltaQBjFzMdcivxpXrHtBEF13MQ2L
P8TgZU/NBxBSQrXq4jrV3ObNe3X7DMf//Ybi8qyGCtlR2TtU9QpT5VB83WDKNeRmNE
upkTHPNTS+qtDyNqODyGSORPAFV0rcIk+ZBRPTO8EVuNJOzgD5pnorcY73pcEf/mhp
Hp14BgwHqFzpsNmFAUoWGx+y0rb7jYVIqnDce/lWDo/PYhHhac1nVx9WFEHHdL7H/5
AJfhL3V20UKx3MnHVpvTUyeN6oWfhPEkRl5gYz+Dl3Wzi9E7KMI1c03lf+KaUm1M3X
XJgebXhfLwNEg==
X-Nifty-SrcIP: [220.150.135.236]
Date: Fri, 12 Aug 2022 08:38:55 +0900
From: Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
To: cygwin AT cygwin DOT com, newlib AT sourceware DOT org
Subject: Re: crash in newlocale()
Message-Id: <20220812083855.55b416d464ec153ea3280f4c@nifty.ne.jp>
In-Reply-To: <YvU960nGyeuJUAPt@calimero.vinschen.de>
References: <YvRbeAzxwtYwhkkE AT venus DOT tony DOT develop-help DOT com>
<20220811211806 DOT bc7f5426ce52f57d1c1538c2 AT nifty DOT ne DOT jp>
<YvU960nGyeuJUAPt AT calimero DOT vinschen DOT de>
X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Mime-Version: 1.0
X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A,
RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

On Thu, 11 Aug 2022 19:35:39 +0200
Corinna Vinschen wrote:
> On Aug 11 21:18, Takashi Yano wrote:
> > On Thu, 11 Aug 2022 11:29:28 +1000
> > Tony Cook wrote:
> > > Hello everyone,
> > > 
> > > While tracking down a crash in development versions of perl the boostrap
> > > miniperl executable was crashing early in the build process:
> > > [...]
> > 
> > I looked into this problem and found the access violation
> > occurs at:
> > newlib/libc/locale/newlocale.c
> > @@ 188,7 @@ _newlocale_r (struct _reent *p, int category_mask, const char *locale,
> > 	if (tmp_locale.lc_cat[i].buf == (const void *) -1)
> > 	  {
> > 	    tmp_locale.lc_cat[i].buf = base->lc_cat[i].buf;
> > 	    base->lc_cat[i].ptr = base->lc_cat[i].buf = NULL; <-- Here!!!
> > 	  }
> > #endif /* __HAVE_LOCALE_INFO__ */
> >       _freelocale_r (p, base);
> > 
> > This is because
> > locale_t st = newlocale(LC_ALL_MASK, "C", (locale_t)0);
> > returns
> >   extern const struct __locale_t __C_locale;
> >   return (struct __locale_t *) &__C_locale;
> > , which is in the const area that cannot be modified.
> > 
> > This seems to be a newlib bug.
> > 
> > I also found following patch solves the issue.
> > 
> > diff --git a/newlib/libc/locale/newlocale.c b/newlib/libc/locale/newlocale.c
> > index 0789d5fd9..1974665ec 100644
> > --- a/newlib/libc/locale/newlocale.c
> > +++ b/newlib/libc/locale/newlocale.c
> > @@ -108,10 +108,12 @@ _newlocale_r (struct _reent *p, int category_mask, const char *locale,
> >      }
> >    /* If the new locale is supposed to be all default locale, just return
> >       a pointer to the default locale. */
> > +#if 0
> >    if ((!base && category_mask == 0)
> >        || (category_mask == LC_VALID_MASK
> >  	  && (!strcmp (locale, "C") || !strcmp (locale, "POSIX"))))
> >      return __get_C_locale ();
> > +#endif
> >    /* Start with setting all values to the default locale values. */
> >    tmp_locale = *__get_C_locale ();
> >    /* Fill out new category strings. */
> 
> I think the right thing to do is to avoid freeing this data, if the base
> locale is the C locale.  I sent a patch to cygwin-patches for review.
> Can you please take a look?

LGTM. Thanks!

-- 
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019