__cxa_finalize and `on_exit'

Martin von Loewis loewis at informatik.hu-berlin.de
Mon Dec 20 11:32:52 UTC 1999


> The problem is that something different needs to happen in the
> integrated and unintegrated cases:

Re-thinking about this, it may not be a problem.

>   o Integrated case
> 
>     Calling __cxa_finalize from the main program, either directly
>     or via atexit, is bad: it means that __cxa_atexit/atexit calls
>     may not be properly interleaved with on_exit.

The draft says that __cxa_finalize is called via DT_FINI from the main
program. In the integrated case, C atexit processing will be done when
this call is made, including both on_exit and __cxa_atexit.

>   o Unintegrated case
> 
>     We need to call __cxa_finalize from the main program to run
>     cleanups.

That would be done via the DT_FINI call. I'm not sure whether this
could come 'too late', though, since atexit processing is already
over.

> One possibility: check a weak variable, defined to a non-zero value in
> an integrated library.  If the variable is non-zero, we don't need to
> register __cxa_finalize for the main program.  If it is zero, then we
> know we've got an unintegrated library, and we have to register
> __cxa_finalize, either in via fini processing or via the C atexit
> routine.  Does that work?

In reconsideration, I don't think this is needed.

Regards,
Martin




More information about the cxx-abi-dev mailing list