atexit/static dtor interleaving
Jonathan Schilling
jls at sco.com
Wed Aug 11 10:07:00 UTC 1999
> Date: Tue, 10 Aug 1999 13:18:17 +0200
> From: Martin von Loewis <loewis at informatik.hu-berlin.de>
>
> > What this implies to me is that atexit, and the part of the runtime
> > library that handles destructors for static objects, must know about
> > each other.
>
> Of the compilers I'm using, only MSVC gets this right - they use
> atexit to register the destructor function.
>
> I think there should be a way to implement the standard requirement no
> matter how stupid the requirement is; I personally think it is good
> that it is specified.
The SCO compiler gets the atexit()/static destructor ordering right,
by having both atexit functions and needed destructor calls placed
on a per-DSO/a.out list that is walked upon DSO unload/a.out termination.
But we do this only for atexit functions registered from the std::atexit()
defined in <cstdlib>, for which we have a completely different implementation
than the C standard library ::atexit() defined in <stdlib.h>.
This is because the C standard library atexit() is used to register functions
for sensitive, system-level tasks (triggering DSO _fini processing, stdio
cleanup, profiling shutdown, etc.) and trying to add C++ semantics to it
proved very troublesome.
Based on a close (perhaps dubious) reading of 18.3, we decided that
the <cstdlib> std::atexit() may exist in a different world from
the <stdlib.h> ::atexit(); it does not have "additional behavior"
relative to the C standard library but instead has its own specification.
Jonathan Schilling SCO, Inc. jls at sco.com
More information about the cxx-abi-dev
mailing list