From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1311 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: thread local storage Date: Mon, 16 Jul 2012 18:18:53 -0400 Message-ID: <20120716221853.GP544@brightrain.aerifal.cx> References: <50046559.3090204@barfooze.de> <50046412.4060609@purdue.edu> <20120716200951.GO544@brightrain.aerifal.cx> <500487D9.4060404@barfooze.de> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1342477184 4767 80.91.229.3 (16 Jul 2012 22:19:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 16 Jul 2012 22:19:44 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1312-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jul 17 00:19:44 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Sqtdn-0004Ai-Dn for gllmg-musl@plane.gmane.org; Tue, 17 Jul 2012 00:19:43 +0200 Original-Received: (qmail 20259 invoked by uid 550); 16 Jul 2012 22:19:42 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 20251 invoked from network); 16 Jul 2012 22:19:42 -0000 Content-Disposition: inline In-Reply-To: <500487D9.4060404@barfooze.de> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:1311 Archived-At: On Mon, Jul 16, 2012 at 11:30:01PM +0200, John Spencer wrote: > On 07/16/2012 10:09 PM, Rich Felker wrote: > > > >This is broken and non-thread-safe. Not a good idea. Instead try: > > thanks, very interesting. > > do you mind if i forward this to the luajit ml ? > looks as if this might fix the problem on OSX/OpenBSD as well. Please do. This is the correct, portable fix. Using __thread or _Thread_local might be prefered to avoid the init/cleanup need when possible, but the POSIX fallback should be used rather than falling back to code that will horribly crash or even yield privilege elevation under multi-threaded use. Rich