| delorie.com/archives/browse.cgi | search |
| 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: | <http://sources.redhat.com/ml/cygwin-developers/> |
| List-Post: | <mailto:cygwin-developers AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-developers-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
| Sender: | cygwin-developers-owner AT cygwin DOT com |
| Delivered-To: | mailing list cygwin-developers AT cygwin DOT com |
| Message-ID: | <3D46AA34.1060609@hekimian.com> |
| 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
gcc:
struct x {
int i;
x() {
i = 0;
}
~x() {
i = -1;
}
};
int
main()
{
static x temp;
return(temp.i);
}
- 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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |