|
Message-ID: <20240830150853.GN10433@brightrain.aerifal.cx> Date: Fri, 30 Aug 2024 11:08:53 -0400 From: Rich Felker <dalias@...c.org> To: JinCheng Li <naiveli233@...look.com> Cc: musl <musl@...ts.openwall.com> Subject: Re: Question about the exit() 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
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.