mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Making exit actually thread-safe
@ 2024-07-24 19:09 Rich Felker
  2024-07-24 20:53 ` [musl] Re: [libc-coord] " Konstantin Belousov
  2024-07-24 21:00 ` [musl] " Zack Weinberg
  0 siblings, 2 replies; 13+ messages in thread
From: Rich Felker @ 2024-07-24 19:09 UTC (permalink / raw)
  To: libc-coord; +Cc: musl, libc-alpha

Inspired by Rust issue 126600, there seems to be renewed interest in
the (non-) thread-safety of exit, namely the C (and copied in POSIX
text) stipulation that calling exit "more than once" results in
undefined behavior.

This language predates threads and thus was certainly written with
recursive calls (via atexit handlers) in mind as the way one might
come to call exit "more than once".

My view is that making calls to exit from multiple threads (one or
more additional threads while the first caller is still acting on
exit) undefined is a mistake and is harmful. There is a clear unique
reasonable behavior for this situation: any remaining callers block
until the first call to exit has finished, at which point they no
longer exist. Leaving exit via longjmp, exceptions, etc. is undefined,
so there are no concerns about what happens in such a situation. The
additional calls to exit all behave as expected: the process
terminates.

Currently there is a glibc tracker item, #31997, and an Austin Group
(POSIX) tracker item, #1845, open for this topic, as well as the
original Rust tracker thread. I have participated in all of these, and
would like to move this forward towards consensus on whether any new
thread-safety requirement should be adopted, and if so, what the
specific semantics should be.

Links:

https://github.com/rust-lang/rust/issues/126600
https://sourceware.org/bugzilla/show_bug.cgi?id=31997
https://austingroupbugs.net/view.php?id=1845

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-07-26 22:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-24 19:09 [musl] Making exit actually thread-safe Rich Felker
2024-07-24 20:53 ` [musl] Re: [libc-coord] " Konstantin Belousov
2024-07-24 21:21   ` enh
2024-07-25  0:19     ` Rich Felker
2024-07-25 12:39       ` enh
2024-07-25 12:48         ` Adhemerval Zanella Netto
2024-07-26 19:56           ` Rich Felker
2024-07-26 21:00           ` Carlos O'Donell
2024-07-26 22:40             ` [musl] Re: [libc-coord] " Gabriel Ravier
2024-07-26 19:38         ` Markus Wichmann
2024-07-26 19:58           ` Rich Felker
2024-07-26 21:06             ` Carlos O'Donell
2024-07-24 21:00 ` [musl] " Zack Weinberg

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).