@@ -323,15 +323,20 @@ impl Error for VarError {
323
323
/// This function is also always safe to call on Windows, in single-threaded
324
324
/// and multi-threaded programs.
325
325
///
326
- /// In multi-threaded programs on other operating systems, you must ensure that
327
- /// are no other threads concurrently writing or *reading*(!) from the
328
- /// environment through functions other than the ones in this module. You are
329
- /// responsible for figuring out how to achieve this, but we strongly suggest
330
- /// not using `set_var` or `remove_var` in multi-threaded programs at all.
331
- ///
332
- /// Most C libraries, including libc itself, do not advertise which functions
333
- /// read from the environment. Even functions from the Rust standard library do
334
- /// that, e.g. for DNS lookups from [`std::net::ToSocketAddrs`].
326
+ /// In multi-threaded programs on other operating systems, we strongly suggest
327
+ /// not using `set_var` or `remove_var` at all. The exact requirement is: you
328
+ /// must ensure that there are no other threads concurrently writing or
329
+ /// *reading*(!) the environment through functions or global variables other
330
+ /// than the ones in this module. The problem is that these operating systems
331
+ /// do not provide a thread-safe way to read the environment, and most C
332
+ /// libraries, including libc itself, do not advertise which functions read
333
+ /// from the environment. Even functions from the Rust standard library may
334
+ /// read the environment without going through this module, e.g. for DNS
335
+ /// lookups from [`std::net::ToSocketAddrs`]. No stable guarantee is made about
336
+ /// which functions may read from the environment in future versions of a
337
+ /// library. All this makes it not practically possible for you to guarantee
338
+ /// that no other thread will read the environment, so the only safe option is
339
+ /// to not use `set_var` or `remove_var` in multi-threaded programs at all.
335
340
///
336
341
/// Discussion of this unsafety on Unix may be found in:
337
342
///
@@ -385,15 +390,20 @@ unsafe fn _set_var(key: &OsStr, value: &OsStr) {
385
390
/// This function is also always safe to call on Windows, in single-threaded
386
391
/// and multi-threaded programs.
387
392
///
388
- /// In multi-threaded programs, you must ensure that are no other threads
389
- /// concurrently writing or *reading*(!) from the environment through functions
390
- /// other than the ones in this module. You are responsible for figuring out
391
- /// how to achieve this, but we strongly suggest not using `set_var` or
392
- /// `remove_var` in multi-threaded programs at all.
393
- ///
394
- /// Most C libraries, including libc itself, do not advertise which functions
395
- /// read from the environment. Even functions from the Rust standard library do
396
- /// that, e.g. for DNS lookups from [`std::net::ToSocketAddrs`].
393
+ /// In multi-threaded programs on other operating systems, we strongly suggest
394
+ /// not using `set_var` or `remove_var` at all. The exact requirement is: you
395
+ /// must ensure that there are no other threads concurrently writing or
396
+ /// *reading*(!) the environment through functions or global variables other
397
+ /// than the ones in this module. The problem is that these operating systems
398
+ /// do not provide a thread-safe way to read the environment, and most C
399
+ /// libraries, including libc itself, do not advertise which functions read
400
+ /// from the environment. Even functions from the Rust standard library may
401
+ /// read the environment without going through this module, e.g. for DNS
402
+ /// lookups from [`std::net::ToSocketAddrs`]. No stable guarantee is made about
403
+ /// which functions may read from the environment in future versions of a
404
+ /// library. All this makes it not practically possible for you to guarantee
405
+ /// that no other thread will read the environment, so the only safe option is
406
+ /// to not use `set_var` or `remove_var` in multi-threaded programs at all.
397
407
///
398
408
/// Discussion of this unsafety on Unix may be found in:
399
409
///
0 commit comments