From: Rich Felker <dalias@libc.org>
To: JinCheng Li <naiveli233@outlook.com>
Cc: musl <musl@lists.openwall.com>
Subject: Re: [musl] Question about the exit()
Date: Fri, 30 Aug 2024 11:08:53 -0400 [thread overview]
Message-ID: <20240830150853.GN10433@brightrain.aerifal.cx> (raw)
In-Reply-To: <SE1P216MB24840DB4017D42E4B93198C59E972@SE1P216MB2484.KORP216.PROD.OUTLOOK.COM>
On Fri, Aug 30, 2024 at 01:34:58PM +0000, JinCheng Li wrote:
> Hi
>
> I have one question in exit().
> Why is the __libc_exit_fini executed after __funcs_on_exit? If some
Because that is the contract.
> 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.
Then that's a bug in the atexit handler. It should not be freeing
anything that could later be needed by a destructor or by any thread
that may still be running concurrent with exit. In general, freeing
anything from an atexit handler is a bug. See Rust issue 126600 where
this is discussed in detail:
https://github.com/rust-lang/rust/issues/126600
> 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.
I don't follow. What do you mean by "registered last"? After what? And
where is this "global variables release" coming from?
Rich
prev parent reply other threads:[~2024-08-30 15:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-30 13:34 JinCheng Li
2024-08-30 15:07 ` Markus Wichmann
2024-08-30 15:08 ` Rich Felker [this message]
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=20240830150853.GN10433@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
--cc=naiveli233@outlook.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).