public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jbuehler@hekimian.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/7458: private static objects not constructed in thread-safe fashion
Date: Wed, 31 Jul 2002 13:06:00 -0000	[thread overview]
Message-ID: <20020731195736.16599.qmail@sources.redhat.com> (raw)


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


             reply	other threads:[~2002-07-31 20:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-31 13:06 jbuehler [this message]
2002-08-01 20:38 cgf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020731195736.16599.qmail@sources.redhat.com \
    --to=jbuehler@hekimian.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).