|
Message-ID:
<SE1P216MB24840DB4017D42E4B93198C59E972@SE1P216MB2484.KORP216.PROD.OUTLOOK.COM>
Date: Fri, 30 Aug 2024 13:34:58 +0000
From: JinCheng Li <naiveli233@...look.com>
To: musl <musl@...ts.openwall.com>
Subject: Question about the exit()
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
Content of type "text/html" skipped
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.