Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Apr 2015 03:57:17 -0700
From:      Steve Kargl <sgk@troutmask.apl.washington.edu>
To:        David Chisnall <theraven@FreeBSD.org>
Cc:        freebsd-standards@freebsd.org
Subject:   Re: newlocale(3) appears to be broken?
Message-ID:  <20150424105717.GA18593@troutmask.apl.washington.edu>
In-Reply-To: <9239D309-A382-4691-B08E-739B545ED865@FreeBSD.org>
References:  <20150423182733.GA14387@troutmask.apl.washington.edu> <9239D309-A382-4691-B08E-739B545ED865@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Apr 24, 2015 at 10:31:14AM +0100, David Chisnall wrote:
> On 23 Apr 2015, at 19:29, Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
> > 
> > It appears that newlocale(3) is broken.
> > 
> > % cat r.c
> > 
> > #include <locale.h>
> > 
> > int
> > main(void)
> > {
> >   locale_t a;
> >   a = newlocale(0, "C", 0);
> >   if (a)
> >      return 0;
> >   else
> >      return 1;
> > }
> > 
> > troutmask:sgk[206] cc -o z -static r.c && ./z
> > Segmentation fault (core dumped)
> > 
> > troutmask:sgk[206] cc -o z -static r.c && ./z
> > Segmentation fault (core dumped)
> > troutmask:sgk[207] gdb782 z z.core
> > [New process 100313]
> > Core was generated by `z'.
> > Program terminated with signal SIGSEGV, Segmentation fault.
> > #0  0x0000000000415798 in newlocale ()
> > (gdb) bt
> > #0  0x0000000000415798 in newlocale ()
> > #1  0x0000000000400434 in main ()
> 
> I can reproduce this, though only with static linking.  Omitting the -static results in the program working correctly.  It appears to be caused by __xlocale_C_ctype being declared const, so the reference count manipulation causes segmentation faults.  I???m a bit surprised that this doesn???t happen in the dynamically linked version.  I???m testing a fix now.
> 
> David

I saw your commit.  Thanks for fixing this so quickly!

-- 
Steve



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150424105717.GA18593>