From: Erik Faye-Lund Date: Tue, 23 Apr 2013 21:27:31 GMT Subject: Re: [PATCH v2 0/2] avoid bogus "recursion detected in die handler" message Message-ID: In-Reply-To: <20130416194418.GA7187@sigill.intra.peff.net> On Tue, Apr 16, 2013 at 9:44 PM, Jeff King wrote: > On Tue, Apr 16, 2013 at 04:13:56PM +0200, Johannes Sixt wrote: > >> > I'm not clear on what you are suggesting. That we protect only the main >> > thread from recursion, or that we drop the check entirely? Or that we >> > implement thread-local storage for this case without using pthread_once? >> >> Anything(*) that does not require pthread_once. A pthread_once >> implementation on Windows would be tricky and voluminous and and on top of >> it very likely to be done differently for gcc and MSVC. I don't like to go >> there if we can avoid it. This seems to have been settled as a "we don't need to go there" already, but just in case; here's an implementation of PTHREAD_MUTEX_INITIALIZER using double-checked locks, and it would probably be repurposable to do pthread_once if needed: https://github.com/kusma/git/commit/c2d7190ed64652c3ac8ea1f2800ff8e7d0b6c01e Yes, it's not pretty, it's error-prone; the best thing would be not to do it.