Re: crash in newlocale()

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib,gmane.os.cygwin
Message-ID <YvYwWiI5qTPer/[email protected]>
On Aug 12 08:38, Takashi Yano wrote:
> 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.
> > > [...]
> > 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!

Thanks for checking!  I pushed the patch with addition release msg
to the 3.3 branch as well.


Corinna
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.