@@ -313,17 +313,26 @@ impl Error for VarError {
313313/// Sets the environment variable `key` to the value `value` for the currently running
314314/// process.
315315///
316- /// Note that while concurrent access to environment variables is safe in Rust,
317- /// some platforms only expose inherently unsafe non-threadsafe APIs for
318- /// inspecting the environment. As a result, extra care needs to be taken when
319- /// auditing calls to unsafe external FFI functions to ensure that any external
320- /// environment accesses are properly synchronized with accesses in Rust.
316+ /// Note that while concurrent access to environment variables ought to be safe
317+ /// in Rust, some platforms only expose inherently unsafe non-threadsafe APIs
318+ /// for inspecting the environment. As a result, using `set_var` or
319+ /// `remove_var` in a multi-threaded Rust program can lead to undefined
320+ /// behavior, for example in combination with DNS lookups from
321+ /// [`std::net::ToSocketAddrs`]. This is a bug
322+ /// ([rust#27970](https://github.com/rust-lang/rust/issues/27970)) and will be
323+ /// fixed in a future version of Rust. Additionally, extra care needs to be
324+ /// taken when auditing calls to unsafe external FFI functions to ensure that
325+ /// any external environment accesses are properly synchronized with accesses
326+ /// in Rust. Since Rust does not expose its environment lock directly, this
327+ /// means that all accesses to the environment must go through Rust's [`var`].
321328///
322329/// Discussion of this unsafety on Unix may be found in:
323330///
324331/// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188)
325332/// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
326333///
334+ /// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs
335+ ///
327336/// # Panics
328337///
329338/// This function may panic if `key` is empty, contains an ASCII equals sign `'='`
@@ -351,17 +360,26 @@ fn _set_var(key: &OsStr, value: &OsStr) {
351360
352361/// Removes an environment variable from the environment of the currently running process.
353362///
354- /// Note that while concurrent access to environment variables is safe in Rust,
355- /// some platforms only expose inherently unsafe non-threadsafe APIs for
356- /// inspecting the environment. As a result extra care needs to be taken when
357- /// auditing calls to unsafe external FFI functions to ensure that any external
358- /// environment accesses are properly synchronized with accesses in Rust.
363+ /// Note that while concurrent access to environment variables ought to be safe
364+ /// in Rust, some platforms only expose inherently unsafe non-threadsafe APIs
365+ /// for inspecting the environment. As a result, using `set_var` or
366+ /// `remove_var` in a multi-threaded Rust program can lead to undefined
367+ /// behavior, for example in combination with DNS lookups from
368+ /// [`std::net::ToSocketAddrs`]. This is a bug
369+ /// ([rust#27970](https://github.com/rust-lang/rust/issues/27970)) and will be
370+ /// fixed in a future version of Rust. Additionally, extra care needs to be
371+ /// taken when auditing calls to unsafe external FFI functions to ensure that
372+ /// any external environment accesses are properly synchronized with accesses
373+ /// in Rust. Since Rust does not expose its environment lock directly, this
374+ /// means that all accesses to the environment must go through Rust's [`var`].
359375///
360376/// Discussion of this unsafety on Unix may be found in:
361377///
362378/// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188)
363379/// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
364380///
381+ /// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs
382+ ///
365383/// # Panics
366384///
367385/// This function may panic if `key` is empty, contains an ASCII equals sign
0 commit comments