Home | History | Annotate | Download | only in stdlib
History log of /src/lib/libc/stdlib/atexit.c
RevisionDateAuthorComments
 1.32  06-Nov-2017  joerg Assert that __cxa_atexit is not used with NULL as DSO. Don't use
__cxa_atexit directly from atexit, they have different behavior.
 1.31  02-Nov-2017  kamil Revert previous on demand.

Rationale:

The DSO handle is a required part of the (external) __cxa_atexit interface.
The atexit mapping is an implementation detail and not part of the public
interface. Doing it directly creates UB as it involves casting function
pointers between incompatible types.

-- Joerg
 1.30  02-Nov-2017  kamil Correct handling of __cxa_atexit(a,b,NULL) in libc

In the NetBSD implementation and suggested by Itanium C++ ABI, we wrap
the atexit(x) call as __cxa_atexit(x,NULL,NULL).

__cxa_atexit() is an internal function for the usage of C++.

Correct a bug that __cxa_atexit(x,y,NULL) is handled in the same way as
atexit(x) (which is simplified to __cxa_atexit(x,NULL,NULL).

This misbehavior has been detected in the Thread Sanitizer port to NetBSD.

Patch reviewed by <christos>

Sponsored by <The NetBSD Foundation>
 1.29  19-Apr-2015  joerg Redo __aeabi_atexit by shuffling the arguments and dropping the code in
libstdc++.
 1.28  18-Apr-2015  joerg Add __aeabi_atexit alias for another case of NIH on ARM.
 1.27  20-Jan-2015  christos Fix non _REENTRANT build.
 1.26  19-Aug-2013  matt branches: 1.26.4;
Put the startup code in .text.startup
 1.25  26-Apr-2013  christos add {at_,}quick_exit(3) from FreeBSD
 1.24  08-Oct-2009  pooka branches: 1.24.6; 1.24.12;
When converting the locking path of mutex+counter to a real recursive
mutex, it's a good idea to convert the unlock path too so that the
recursive mutex gets released as many times as it was locked.
Fixes pthread + cxa deadlock.
 1.23  28-Apr-2008  martin branches: 1.23.8;
Remove clause 3 and 4 from TNF licenses
 1.22  25-Feb-2008  xtraeme branches: 1.22.2;
There's no need to do the mutex_trylock dance anymore in __cxa_finalize(),
just using mutex_lock() is enough.
 1.21  25-Feb-2008  xtraeme Add a comment for __libc_atexit_init() missed in previous that was
available in the original patch.
 1.20  25-Feb-2008  xtraeme Make the atexit mutex recursive and initialize it in __libc_init()
as suggested by ad@, based on the patch provided by Sverre Froyen
in lib/37654.

Reviewed by ad@ and jmcneill@.
 1.19  08-Aug-2007  kristerw branches: 1.19.2; 1.19.6;
Keep track of atexit functions that are added while processing
atexit functions, to ensure that the new functions will be called.
 1.18  08-Aug-2007  kristerw Ensure that the struct atexit_handler has been removed from the list
of pending atexit handlers before the structure is reused. This prevents
__cxa_finalize from going into an infinite loop when an atexit handler
register a new atexit handler as in:

#include <stdlib.h>

void two(void) {
}

void one(void) {
atexit(two);
}

int main(void) {
atexit(one);
return 0;
}
 1.17  12-Jun-2005  lukem branches: 1.17.4; 1.17.6;
Add missing __RCSID()
 1.16  19-Mar-2003  nathanw branches: 1.16.6;
When implementing a recursive mutex, it helps if you remember to
decrement the recursion count.

Fixes the problem of uic dying with a no-next-thread assertion while
building kdeadmin3; reported by Perry Metzger and others on
tech-pkg.
 1.15  04-Mar-2003  thorpej Fix lib/20558:
A dynamically linked program invokes the rtld cleanup routine via
an atexit handler. This rtld cleanup routine invokes _fini() for
shared libraries, which in-turn invoke __cxa_finalize() with their
DSO handle. By luck, this happens to work okay for non-threaded
programs, but for a threaded program, this leads to deadlock (sometimes
manifested as an assertion failure, if the program didn't actually
create any threads).

Fixed by teaching __cxa_finalize() that it can be recursively invoked,
adjusting the handler list manipulation accordingly.
 1.14  01-Mar-2003  thorpej Rewrite atexit(3), and add support for __cxa_atexit()/__cxa_finalize(),
as specified by the C++ ABI for Itanium. Despite the ABI document's name,
many of the items in it are implemented for other architectures.

See the following URL for a reference:

http://www.codesourcery.com/cxx-abi/abi.html#dso-dtor

Fixes lib/18379 (from Joel Baker).
 1.13  18-Jan-2003  thorpej Merge the nathanw_sa branch.
 1.12  20-Sep-1999  lukem branches: 1.12.10;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.
 1.11  16-Sep-1999  lukem * use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif
 1.10  18-Oct-1998  kleink Protect __atexit manipulation and traversal with a mutex.
 1.9  03-Feb-1998  perry remove obsolete register declarations
 1.8  30-Jan-1998  perry update to lite-2
 1.7  13-Jul-1997  christos Add local.h for local prototypes.
Fix namespace issues for strtoq and strtouq
Fix gcc warnings.
Fix RCSID's
 1.6  28-Dec-1995  thorpej New-style RCS ids.
 1.5  14-Jun-1995  jtc define __atexit pointer
 1.4  28-Feb-1995  jtc remove unneeded "#include <stddef.h>"
 1.3  26-Aug-1993  jtc Declare rcsid strings so they are stored in text segment.
 1.2  01-Aug-1993  mycroft Add RCS identifiers.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  30-Jan-1998  perry import lite-2
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.12.10.1  08-Aug-2001  nathanw _REENT -> _REENTRANT
 1.16.6.1  23-Sep-2007  bouyer Pull up following revision(s) (requested by kristerw in ticket #1843):
lib/libc/stdlib/atexit.c: revisions 1.18, 1.19
Ensure that the struct atexit_handler has been removed from the list
of pending atexit handlers before the structure is reused. This
prevents libc from going into an infinite loop, or to fail
to call registered atexit-handlers in some cases.
 1.17.6.1  03-Sep-2007  wrstuden Sync w/ NetBSD-4-RC_1
 1.17.4.1  28-Aug-2007  liamjfoy Pull up following revision(s) (requested by kristerw in ticket #839):
lib/libc/stdlib/atexit.c: revision 1.18
lib/libc/stdlib/atexit.c: revision 1.19
Ensure that the struct atexit_handler has been removed from the list
of pending atexit handlers before the structure is reused. This prevents
__cxa_finalize from going into an infinite loop when an atexit handler
register a new atexit handler.

Keep track of atexit functions that are added while processing
atexit functions, to ensure that the new functions will be called.
 1.19.6.1  24-Mar-2008  keiichi sync with head.
 1.19.2.1  23-Mar-2008  matt sync with HEAD
 1.22.2.1  18-May-2008  yamt sync with head.
 1.23.8.2  28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.23.8.1  28-Apr-2008  martin file atexit.c was added on branch christos-time_t on 2008-04-28 20:23:01 +0000
 1.24.12.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.12.1  23-Jun-2013  tls resync from head
 1.24.6.1  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.26.4.2  21-Apr-2015  snj Pull up following revision(s) (requested by joerg in ticket #712):
lib/libc/stdlib/atexit.c: revision 1.29
external/gpl3/gcc/dist/libstdc++-v3/libsupc++/atexit_arm.cc: revision 1.2
Redo __aeabi_atexit by shuffling the arguments and dropping the code in
libstdc++.
 1.26.4.1  19-Apr-2015  msaitoh Pull up following revision(s) (requested by joerg in ticket #708):
lib/libc/stdlib/atexit.c: revision 1.28
Add __aeabi_atexit alias for another case of NIH on ARM.

RSS XML Feed