From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20173 invoked by alias); 31 Jul 2002 20:06:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 20146 invoked by uid 71); 31 Jul 2002 20:06:02 -0000 Resent-Date: 31 Jul 2002 20:06:02 -0000 Resent-Message-ID: <20020731200602.20145.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, jbuehler@hekimian.com Received: (qmail 16600 invoked by uid 61); 31 Jul 2002 19:57:36 -0000 Message-Id: <20020731195736.16599.qmail@sources.redhat.com> Date: Wed, 31 Jul 2002 13:06:00 -0000 From: jbuehler@hekimian.com Reply-To: jbuehler@hekimian.com To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/7458: private static objects not constructed in thread-safe fashion X-SW-Source: 2002-07/txt/msg00819.txt.bz2 List-Id: >Number: 7458 >Category: c++ >Synopsis: private static objects not constructed in thread-safe fashion >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Jul 31 13:06:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Joe Buehler >Release: 2.95, 3.0.2 >Organization: >Environment: Cygwin, but generated code looks the same on AIX, HPUX as far as I can tell >Description: The attached C++ generates code that is not thread-safe, when using the gcc 2.95 prebuilt for Cygwin and installable via the Cygwin installer. gcc inserts code at the top of f() to take care of construction of the "temp" instance, and to schedule its destruction at program exit time, using atexit(). The code that does this is not thread-safe -- two calls to f() around the same time can cause double-construction, double calls to atexit(), etc. Is this a gcc bug, or a result of the way that the gcc I am using has been configured? Or is some gcc option supposed to be used that will take care of this? My apologies if this has been asked a million times -- I did not find anything in GNATS for gcc. Joe Buehler struct x { int i; x() { i = 0; } ~x() { i = -1; } }; int f() { static x temp; return(temp.i); } >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: