From: JinCheng Li <naiveli233@outlook.com>
To: musl <musl@lists.openwall.com>
Subject: [musl] Question about the exit()
Date: Fri, 30 Aug 2024 13:34:58 +0000 [thread overview]
Message-ID: <SE1P216MB24840DB4017D42E4B93198C59E972@SE1P216MB2484.KORP216.PROD.OUTLOOK.COM> (raw)
[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]
Hi
I have one question in exit().
Why is the __libc_exit_fini executed after __funcs_on_exit? If some finalized functions in .fini_array access global variables which is registered by __cxa_atexit and will be release in __funcs_on_exit, we may run into some crash during __libc_exit_fini executaion.
_Noreturn void exit(int code)
{
__funcs_on_exit();
__libc_exit_fini();
__stdio_exit();
_Exit(code);
}
In bionic, I found the fini_array functions may be registered at the last before we execute main function and called firstly in exit(before global variables release) . Its order looks like completely opposite to musl.
__noreturn void __libc_init(void* raw_args,
void (*onexit)(void) __unused,
int (*slingshot)(int, char**, char**),
structors_array_t const * const structors) {
......
if (structors->fini_array) {
__cxa_atexit(__libc_fini,structors->fini_array,nullptr);
}
......
exit(slingshot(args.argc - __libc_shared_globals()->initial_linker_arg_count,
args.argv + __libc_shared_globals()->initial_linker_arg_count,
args.envp));
}
Best
Li
[-- Attachment #2: Type: text/html, Size: 8363 bytes --]
next reply other threads:[~2024-08-30 13:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-30 13:34 JinCheng Li [this message]
2024-08-30 15:07 ` Markus Wichmann
2024-08-30 15:08 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=SE1P216MB24840DB4017D42E4B93198C59E972@SE1P216MB2484.KORP216.PROD.OUTLOOK.COM \
--to=naiveli233@outlook.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).