public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12159] New: static C++ objects inside global functions (within a shared library) cause crash on program exit on Linux
@ 2003-09-03 21:34 tim dot crook at adobe dot com
2003-09-07 3:07 ` [Bug c++/12159] " pinskia at gcc dot gnu dot org
2003-09-09 14:41 ` tim dot crook at adobe dot com
0 siblings, 2 replies; 3+ messages in thread
From: tim dot crook at adobe dot com @ 2003-09-03 21:34 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12159
Summary: static C++ objects inside global functions (within a
shared library) cause crash on program exit on Linux
Product: gcc
Version: 3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tim dot crook at adobe dot com
CC: gcc-bugs at gcc dot gnu dot org
If you have a function like:
ComplexClass
foo ()
{
static ComplexClass blah;
return blah;
}
in a shared library and call it at least once (to initialize it with the
constructor), when the shared library is unloaded before main terminates, your
program will have a segment fault.
Under the covers, the code being generated for destruction of "blah" is done
using the C function atexit. A function "__tcf_0" was generated by the compiler
to do the cleanup - I turned off inlining.
By the definition in the Linux man page, the functions registered with atexit
are called on program termination. As the code segment for the shared library
has been deleted, this causes a memory fault.
On Solaris, the man page defines atexit functions as being called when EITHER
objects are unloaded OR program termination occurs. As a result, this problem
never happens on Solaris.
The solution to this problem may be to hook __tcf_0 into the function _fini,
which is called when a shared library is unloaded. It appears that for each
module compiled with at least one global static inside a global function, a
__tcf_0 is generated.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/12159] static C++ objects inside global functions (within a shared library) cause crash on program exit on Linux
2003-09-03 21:34 [Bug c++/12159] New: static C++ objects inside global functions (within a shared library) cause crash on program exit on Linux tim dot crook at adobe dot com
@ 2003-09-07 3:07 ` pinskia at gcc dot gnu dot org
2003-09-09 14:41 ` tim dot crook at adobe dot com
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-09-07 3:07 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12159
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
------- Additional Comments From pinskia at gcc dot gnu dot org 2003-09-07 03:07 -------
This is not a GCC bug but rather a glibc bug (report it to them) as we have no control over
when functions are called when dealing with shared libraries.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/12159] static C++ objects inside global functions (within a shared library) cause crash on program exit on Linux
2003-09-03 21:34 [Bug c++/12159] New: static C++ objects inside global functions (within a shared library) cause crash on program exit on Linux tim dot crook at adobe dot com
2003-09-07 3:07 ` [Bug c++/12159] " pinskia at gcc dot gnu dot org
@ 2003-09-09 14:41 ` tim dot crook at adobe dot com
1 sibling, 0 replies; 3+ messages in thread
From: tim dot crook at adobe dot com @ 2003-09-09 14:41 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12159
------- Additional Comments From tim dot crook at adobe dot com 2003-09-09 14:41 -------
Subject: RE: static C++ objects inside global functions (w
ithin a shared library) cause crash on program exit on Linux
I think this bug can be dropped. I found out that configuring gcc with
--enable-__cxa_atexit eliminates the problem. Using -fuse-cxa-atexit didn't
seem sufficient - strange.
-----Original Message-----
From: pinskia at gcc dot gnu dot org [mailto:gcc-bugzilla@gcc.gnu.org]
Sent: Saturday, September 06, 2003 11:08 PM
To: tim.crook@adobe.com
Subject: [Bug c++/12159] static C++ objects inside global functions
(within a shared library) cause crash on program exit on Linux
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12159
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
------- Additional Comments From pinskia at gcc dot gnu dot org 2003-09-07
03:07 -------
This is not a GCC bug but rather a glibc bug (report it to them) as we have
no control over
when functions are called when dealing with shared libraries.
------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-09-09 14:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-03 21:34 [Bug c++/12159] New: static C++ objects inside global functions (within a shared library) cause crash on program exit on Linux tim dot crook at adobe dot com
2003-09-07 3:07 ` [Bug c++/12159] " pinskia at gcc dot gnu dot org
2003-09-09 14:41 ` tim dot crook at adobe dot com
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).