Mail Archives: cygwin-developers/2002/07/30/11:01:13

Mailing-List: contact cygwin-developers-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT cygwin DOT com>
List-Archive: <>
List-Post: <mailto:cygwin-developers AT cygwin DOT com>
List-Help: <mailto:cygwin-developers-help AT cygwin DOT com>, <>
Sender: cygwin-developers-owner AT cygwin DOT com
Delivered-To: mailing list cygwin-developers AT cygwin DOT com
Message-ID: <>
Date: Tue, 30 Jul 2002 11:01:08 -0400
X-Sybari-Trust: e387bc9f b923d9bf 0879ee9b 00000109
From: Joe Buehler <jbuehler AT hekimian DOT com>
Reply-To: joseph DOT buehler AT spirentcom DOT com
Organization: Spirent Communications
User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.0) Gecko/20020530
X-Accept-Language: en-us, en
MIME-Version: 1.0
CC: Cygwin Developers <cygwin-developers AT cygwin DOT com>
Subject: gcc problem with static instance destructors
References: <3D46828F DOT 6090802 AT hekimian DOT com>

Looking at the code generated by gcc, it looks like it generates
code that is not thread-safe in a certain case.

It appears that static instances inside functions cause gcc
to generate a call to atexit() to call the destructor at
program exit time.

Compile the following and look at the assembly generated by

struct x {
   int i;
   x() {
     i = 0;
   ~x() {
     i = -1;

   static x temp;

- The code that is generated to call atexit() does not look thread-safe.
   (handling of the flag variable that is tested to prevent duplicate calls)

- In addition, atexit() itself is not thread-safe.

So it looks like functions in cygwin that have internal static class instances
could be a serious source of problems.

This is using gcc-2.95.3-5.

Joe Buehler

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019