Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lock guarantee from std::env::{set_var, remove_var} #125937

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 20 additions & 22 deletions library/std/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,16 @@ impl Error for VarError {
/// In multi-threaded programs on other operating systems, we strongly suggest
/// not using `set_var` or `remove_var` at all. The exact requirement is: you
/// must ensure that there are no other threads concurrently writing or
/// *reading*(!) the environment through functions or global variables other
/// than the ones in this module. The problem is that these operating systems
/// do not provide a thread-safe way to read the environment, and most C
/// libraries, including libc itself, do not advertise which functions read
/// from the environment. Even functions from the Rust standard library may
/// read the environment without going through this module, e.g. for DNS
/// lookups from [`std::net::ToSocketAddrs`]. No stable guarantee is made about
/// which functions may read from the environment in future versions of a
/// library. All this makes it not practically possible for you to guarantee
/// that no other thread will read the environment, so the only safe option is
/// to not use `set_var` or `remove_var` in multi-threaded programs at all.
/// *reading*(!) the environment through functions or global variables. The
/// problem is that these operating systems do not provide a thread-safe way to
/// read the environment, and most C libraries, including libc itself, do not
/// advertise which functions read from the environment. Even some functions
/// from the Rust standard library read the environment, e.g. for DNS lookups
/// from [`std::net::ToSocketAddrs`]. No stable guarantee is made about which
/// functions may read from the environment in future versions of a library.
/// All this makes it not practically possible for you to guarantee that no
/// other thread will read the environment, so the only safe option is to not
/// use `set_var` or `remove_var` in multi-threaded programs at all.
///
/// Discussion of this unsafety on Unix may be found in:
///
Expand Down Expand Up @@ -393,17 +392,16 @@ unsafe fn _set_var(key: &OsStr, value: &OsStr) {
/// In multi-threaded programs on other operating systems, we strongly suggest
/// not using `set_var` or `remove_var` at all. The exact requirement is: you
/// must ensure that there are no other threads concurrently writing or
/// *reading*(!) the environment through functions or global variables other
/// than the ones in this module. The problem is that these operating systems
/// do not provide a thread-safe way to read the environment, and most C
/// libraries, including libc itself, do not advertise which functions read
/// from the environment. Even functions from the Rust standard library may
/// read the environment without going through this module, e.g. for DNS
/// lookups from [`std::net::ToSocketAddrs`]. No stable guarantee is made about
/// which functions may read from the environment in future versions of a
/// library. All this makes it not practically possible for you to guarantee
/// that no other thread will read the environment, so the only safe option is
/// to not use `set_var` or `remove_var` in multi-threaded programs at all.
/// *reading*(!) the environment through functions or global variables. The
/// problem is that these operating systems do not provide a thread-safe way to
/// read the environment, and most C libraries, including libc itself, do not
/// advertise which functions read from the environment. Even some functions
/// from the Rust standard library read the environment, e.g. for DNS lookups
/// from [`std::net::ToSocketAddrs`]. No stable guarantee is made about which
/// functions may read from the environment in future versions of a library.
/// All this makes it not practically possible for you to guarantee that no
/// other thread will read the environment, so the only safe option is to not
/// use `set_var` or `remove_var` in multi-threaded programs at all.
///
/// Discussion of this unsafety on Unix may be found in:
///
Expand Down
Loading