From owner-freebsd-standards@FreeBSD.ORG Fri Apr 24 10:57:19 2015 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8842519F; Fri, 24 Apr 2015 10:57:19 +0000 (UTC) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 696C718E3; Fri, 24 Apr 2015 10:57:19 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.14.9/8.14.9) with ESMTP id t3OAvISj018637 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 24 Apr 2015 03:57:18 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.9/8.14.9/Submit) id t3OAvIHh018636; Fri, 24 Apr 2015 03:57:18 -0700 (PDT) (envelope-from sgk) Date: Fri, 24 Apr 2015 03:57:17 -0700 From: Steve Kargl To: David Chisnall Cc: freebsd-standards@freebsd.org Subject: Re: newlocale(3) appears to be broken? Message-ID: <20150424105717.GA18593@troutmask.apl.washington.edu> References: <20150423182733.GA14387@troutmask.apl.washington.edu> <9239D309-A382-4691-B08E-739B545ED865@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9239D309-A382-4691-B08E-739B545ED865@FreeBSD.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Apr 2015 10:57:19 -0000 On Fri, Apr 24, 2015 at 10:31:14AM +0100, David Chisnall wrote: > On 23 Apr 2015, at 19:29, Steve Kargl wrote: > > > > It appears that newlocale(3) is broken. > > > > % cat r.c > > > > #include > > > > 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