mirror of
https://github.com/apache/nuttx.git
synced 2026-09-29 10:34:23 +00:00
|
Some checks are pending
Build Documentation / build-html (push) Waiting to run
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
atexit_call_exitfuncs() cached its loop bound on entry
(for (idx = aehead->nfuncs - 1; idx >= 0; idx--)), while
atexit_register() appends new entries at funcs[nfuncs] and bumps nfuncs.
Any function registered by an exit handler via atexit() / on_exit() /
__cxa_atexit() lands above the cached bound and is never invoked, even
though the registration returns OK.
This contradicts the exit(3) documentation that NuttX mirrors verbatim
in its own exit() docstring (libs/libc/stdlib/lib_exit.c):
It is possible for one of these functions to use atexit(3) or
on_exit(3) to register an additional function to be executed
during exit processing; the new registration is added to the
front of the list of functions that remain to be called.
The same restructure closes a second defect: atexit_call_exitfuncs()
read and cleared the task-group-shared ta_exit list without holding
ta_lock, while atexit_register() takes it ("The following must be
atomic"). Entries are now claimed under the lock and the handler is
invoked with the lock released, so a handler re-entering
atexit_register() cannot deadlock (also safe with the non-recursive
nxmutex used here).
Evidence: exit(3) man page, DESCRIPTION -
https://man7.org/linux/man-pages/man3/exit.3.html
NuttX mirrors this passage verbatim in its own exit() docstring --
|
||
|---|---|---|
| .. | ||
| CMakeLists.txt | ||
| Kconfig | ||
| lib_abort.c | ||
| lib_abs.c | ||
| lib_aligned_alloc.c | ||
| lib_arc4random.c | ||
| lib_atexit.c | ||
| lib_atof.c | ||
| lib_atoi.c | ||
| lib_atol.c | ||
| lib_atoll.c | ||
| lib_bsearch.c | ||
| lib_checkbase.c | ||
| lib_div.c | ||
| lib_exit.c | ||
| lib_getprogname.c | ||
| lib_itoa.c | ||
| lib_labs.c | ||
| lib_ldiv.c | ||
| lib_llabs.c | ||
| lib_lldiv.c | ||
| lib_mblen.c | ||
| lib_mbstowcs.c | ||
| lib_mbtowc.c | ||
| lib_mkdtemp.c | ||
| lib_mkstemp.c | ||
| lib_mktemp.c | ||
| lib_openpty.c | ||
| lib_posix_memalign.c | ||
| lib_ptsname.c | ||
| lib_ptsnamer.c | ||
| lib_qsort.c | ||
| lib_rand.c | ||
| lib_rand48.c | ||
| lib_reallocarray.c | ||
| lib_realpath.c | ||
| lib_srand.c | ||
| lib_strtol.c | ||
| lib_strtold.c | ||
| lib_strtoll.c | ||
| lib_strtoul.c | ||
| lib_strtoull.c | ||
| lib_unlockpt.c | ||
| lib_valloc.c | ||
| lib_wcstombs.c | ||
| lib_wctomb.c | ||
| Make.defs | ||