This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Re: gcc static constructor multi-threading flaw
- From: Christopher Faylor <cgf at redhat dot com>
- To: cygwin-developers at cygwin dot com
- Date: Wed, 5 Mar 2003 00:08:09 -0500
- Subject: Re: gcc static constructor multi-threading flaw
- References: <3E4D06B8.5010306@hekimian.com>
- Reply-to: cygwin-developers at cygwin dot com
On Fri, Feb 14, 2003 at 10:09:44AM -0500, Joe Buehler wrote:
>Would you accept patches to gcc / cygwin to add locking to
>function-private static object constuction?
>
>Gcc generates calls to atexit() when entering a function that has a
>private static object. It does this to schedule a call to the
>destructor at program exit time.
>
>The atexit() function is not thread-safe, however. I posted an
>explanation to the newlib list, but looking at the newlib code, it
>appears that newlib is not really set up for locking, so a fix is
>probably not going to be forthcoming from there.
>
>One possible fix is to have gcc call a wrapper function that performs
>locking and then calls atexit(). I suppose another way to do it
>without touching gcc is #define manipulation to replace atexit() with a
>Cygwin wrapper.
Since neither gcc nor newlib have responded to this problem, I've
added a wrapper in cygwin. It will be in 1.3.21.
cgf