__cxa_finalize and `on_exit'
Jason Merrill
jason at cygnus.com
Sun Dec 19 18:02:49 UTC 1999
>>>>> Martin von Loewis <loewis at informatik.hu-berlin.de> writes:
> Then, of course, the question is how to run the __cxa_atexit list at
> the end of the program. To do so, the proposal is to put a
> __cxa_finalize call into the .fini section.
> Unfortunately, it seems that this approach breaks the case when you do
> integrate the C and C++ libraries; in this case, the extra call gets
> in the way of extern "C" atexit processing, which must be placed into
> the runtime system very cautiously.
How so? I would think you could just register __cxa_finalize (NULL) (or
equivalent) with the C atexit. Then exit runs all the destructors, and the
calls in .fini do nothing, because everything has already been
deregistered. The atexit chain is run before .fini stuff, I'm pretty sure.
> My proposal: it is left unspecified by the ABI how exactly the
> __cxa_atexit list is invoked - whoever provides the implementation of
> __cxa_atexit and __cxa_finalize is also responsible for having the
> finalizers called at the right point in time (i.e. as a result of
> std::exit invocation).
That won't work; anything that involves .fini must be specified by the ABI.
Jason
More information about the cxx-abi-dev
mailing list