about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-05-14 07:15:51 +0000
committerbors <bors@rust-lang.org>2015-05-14 07:15:51 +0000
commit0a1a53d6933b53b804269ce236760847c5dd00fa (patch)
tree62c6473f672213d5db737ffb671291d583b3080e /src/libstd
parente77b03d783b5c9df88f1f743fe29615db43e1dda (diff)
parent44a5bf1b7d8d16e73ab5631c4dd6bd5107079c5f (diff)
downloadrust-0a1a53d6933b53b804269ce236760847c5dd00fa.tar.gz
rust-0a1a53d6933b53b804269ce236760847c5dd00fa.zip
Auto merge of #24741 - cgwalters:note-setenv-and-unsetenv-are-not-threadsafe, r=alexcrichton
See:
https://sourceware.org/bugzilla/show_bug.cgi?id=4887#c9
https://bugs.freedesktop.org/show_bug.cgi?id=65681

I just noticed this while talking to someone who was using
`os.environ['FOO'] = 'BAR'` in Python and since I'm learning Rust, I
was curious if it did anything special here (and the answer appears to
be no).

Java got this right by disallowing `setenv()` from the start.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/env.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libstd/env.rs b/src/libstd/env.rs
index 82999a47e56..126ef38b918 100644
--- a/src/libstd/env.rs
+++ b/src/libstd/env.rs
@@ -243,6 +243,17 @@ impl Error for VarError {
 /// Sets the environment variable `k` to the value `v` for the currently running
 /// process.
 ///
+/// Note that while concurrent access to environment variables is safe in Rust,
+/// some platforms only expose inherently unsafe non-threadsafe APIs for
+/// inspecting the environment. As a result extra care needs to be taken when
+/// auditing calls to unsafe external FFI functions to ensure that any external
+/// environment accesses are properly synchronized with accesses in Rust.
+///
+/// Discussion of this unsafety on Unix may be found in:
+///
+///  - [Austin Group Bugzilla](http://austingroupbugs.net/view.php?id=188)
+///  - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
+///
 /// # Examples
 ///
 /// ```
@@ -260,6 +271,17 @@ pub fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(k: K, v: V) {
 
 /// Removes an environment variable from the environment of the currently running process.
 ///
+/// Note that while concurrent access to environment variables is safe in Rust,
+/// some platforms only expose inherently unsafe non-threadsafe APIs for
+/// inspecting the environment. As a result extra care needs to be taken when
+/// auditing calls to unsafe external FFI functions to ensure that any external
+/// environment accesses are properly synchronized with accesses in Rust.
+///
+/// Discussion of this unsafety on Unix may be found in:
+///
+///  - [Austin Group Bugzilla](http://austingroupbugs.net/view.php?id=188)
+///  - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
+///
 /// # Examples
 ///
 /// ```