Bug 23552 - destructors for function scope statics run at exit
destructors for function scope statics run at exit
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.0
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-01-07 14:58 EST by David Baron
Modified: 2007-04-18 12:30 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-01-07 15:02:50 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
bug23552.tar - contains Makefile, statictest.cpp, libstatictest.cpp (10.00 KB, application/x-tar)
2001-01-07 15:02 EST, David Baron
no flags Details

  None (edit)
Description David Baron 2001-01-07 14:58:28 EST
Destructors for static objects in function scope are run at exit (using
calls to atexit()).  This causes a segfault on exit when the destructor is
in a shared library that has since been closed.  IMO, the destructors ought
to be run when the shared library is unloaded (as I think they are for
static objects with global scope).  I haven't seen anything in the C++
standard that forbids that, although I haven't looked very closely.

(This is one reason mozilla doesn't unload shared libraries, although not
the only one. There are only a handful of changes that would need to be
made in Mozilla to work around this, though, and I've made most of them
already.)

I'll attach a tar file containing a simple testcase.

I wrote the testcase with gcc-2.96-69, although I've seen this happen in
older versions as well.
Comment 1 David Baron 2001-01-07 15:02:47 EST
Created attachment 7204 [details]
bug23552.tar - contains Makefile, statictest.cpp, libstatictest.cpp
Comment 2 Jakub Jelinek 2001-01-11 17:46:44 EST
You could try building the shared C++ library with
-fuse-cxa-atexit, I admit I haven't tried it yet but it should work.
Comment 3 David Baron 2001-01-11 18:18:17 EST
Yup, that works.

Note You need to log in before you can comment on or make changes to this bug.