public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7458: private static objects not constructed in thread-safe fashion
@ 2002-08-01 20:38 cgf
  0 siblings, 0 replies; 2+ messages in thread
From: cgf @ 2002-08-01 20:38 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, jbuehler, nobody

Synopsis: private static objects not constructed in thread-safe fashion

State-Changed-From-To: open->closed
State-Changed-By: cgf
State-Changed-When: Thu Aug  1 20:38:39 2002
State-Changed-Why:
    The non-test version of gcc in the cygwin package was not built with thread support enabled.  So there is no guarantee that it will be thread-safe.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7458


^ permalink raw reply	[flat|nested] 2+ messages in thread

* c++/7458: private static objects not constructed in thread-safe fashion
@ 2002-07-31 13:06 jbuehler
  0 siblings, 0 replies; 2+ messages in thread
From: jbuehler @ 2002-07-31 13:06 UTC (permalink / raw)
  To: gcc-gnats


>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:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-08-02  3:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-01 20:38 c++/7458: private static objects not constructed in thread-safe fashion cgf
  -- strict thread matches above, loose matches on Subject: below --
2002-07-31 13:06 jbuehler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).