Skip to content

Commit

Permalink
Update library/std/src/sys/pal/common/exit_guard.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Ralf Jung <post@ralfj.de>
  • Loading branch information
zachs18 and RalfJung authored Jul 5, 2024
1 parent 079f999 commit cf300a7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions std/src/sys/pal/common/exit_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ cfg_if::cfg_if! {
if #[cfg(target_os = "linux")] {
/// Mitigation for <https://github.com/rust-lang/rust/issues/126600>
///
/// On UNIX-like platforms (where `libc::exit` may not be thread-safe), ensure that only one
/// On glibc, `libc::exit` has been observed to not always be thread-safe.
/// It is currently unclear whether that is a glibc bug or allowed by the standard.
/// To mitigate this problem, we ensure that only one
/// Rust thread calls `libc::exit` (or returns from `main`) by calling this function before
/// calling `libc::exit` (or returning from `main`).
///
/// Technically not enough to ensure soundness, since other code directly calling
/// libc::exit will still race with this.
/// Technically, this is not enough to ensure soundness, since other code directly calling
/// `libc::exit` will still race with this.
///
/// *This function does not itself call `libc::exit`.* This is so it can also be used
/// to guard returning from `main`.
Expand Down

0 comments on commit cf300a7

Please sign in to comment.