@@ -313,11 +313,18 @@ 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///
@@ -351,11 +358,18 @@ fn _set_var(key: &OsStr, value: &OsStr) {
351358
352359/// Removes an environment variable from the environment of the currently running process.
353360///
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.
361+ /// Note that while concurrent access to environment variables ought to be safe
362+ /// in Rust, some platforms only expose inherently unsafe non-threadsafe APIs
363+ /// for inspecting the environment. As a result, using `set_var` or
364+ /// `remove_var` in a multi-threaded Rust program can lead to undefined
365+ /// behavior, for example in combination with DNS lookups from
366+ /// [`std::net::ToSocketAddrs`]. This is a bug
367+ /// ([rust#27970](https://github.com/rust-lang/rust/issues/27970)) and will be
368+ /// fixed in a future version of Rust. Additionally, extra care needs to be
369+ /// taken when auditing calls to unsafe external FFI functions to ensure that
370+ /// any external environment accesses are properly synchronized with accesses
371+ /// in Rust. Since Rust does not expose its environment lock directly, this
372+ /// means that all accesses to the environment must go through Rust's [`var`].
359373///
360374/// Discussion of this unsafety on Unix may be found in:
361375///
0 commit comments