Re: [PATCH v2 0/2] avoid bogus "recursion detected in die handler" message
- From
Erik Faye-Lund <kusmabite@gmail.com>
- Date
- Apr 23, 2013, 21:27 UTC
- Message-ID
- <CABPQNSbdYSbb5KrMDp8gKPTJcbjq2j91G3kJwrTMz=rJUydGuA@mail.gmail.com>
- In-Reply-To
- <20130416194418.GA7187@sigill.intra.peff.net>
On Tue, Apr 16, 2013 at 9:44 PM, Jeff King <peff@peff.net> wrote:
Show 10 quoted lines
> 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.