diff options
| author | bors <bors@rust-lang.org> | 2018-08-09 07:30:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-08-09 07:30:14 +0000 |
| commit | fbb6275f4fd6cf774e1789fabfacae7248c45021 (patch) | |
| tree | f66469baf6a3a33dad86eb02c203c66115a816bb /src/libstd/sys/unix/mutex.rs | |
| parent | 76b69a604ee0d70be1edfa2828c769dc1b148d13 (diff) | |
| parent | 25db84206b681731960d88558bc53640fe117b09 (diff) | |
| download | rust-fbb6275f4fd6cf774e1789fabfacae7248c45021.tar.gz rust-fbb6275f4fd6cf774e1789fabfacae7248c45021.zip | |
Auto merge of #53108 - RalfJung:mutex, r=alexcrichton
clarify partially initialized Mutex issues Using a `sys_common::mutex::Mutex` without calling `init` is dangerous, and yet there are some places that do this. I tried to find all of them and add an appropriate comment about reentrancy. I found two places where (I think) reentrancy can actually occur, and was not able to come up with an argument for why this is okay. Someone who knows `io::lazy` and/or `sys_common::at_exit_imp` should have a careful look at this.
Diffstat (limited to 'src/libstd/sys/unix/mutex.rs')
| -rw-r--r-- | src/libstd/sys/unix/mutex.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libstd/sys/unix/mutex.rs b/src/libstd/sys/unix/mutex.rs index 60b03cdbeb0..1d447de1134 100644 --- a/src/libstd/sys/unix/mutex.rs +++ b/src/libstd/sys/unix/mutex.rs @@ -25,8 +25,10 @@ unsafe impl Sync for Mutex {} #[allow(dead_code)] // sys isn't exported yet impl Mutex { pub const fn new() -> Mutex { - // Might be moved and address is changing it is better to avoid - // initialization of potentially opaque OS data before it landed + // Might be moved to a different address, so it is better to avoid + // initialization of potentially opaque OS data before it landed. + // Be very careful using this newly constructed `Mutex`, reentrant + // locking is undefined behavior until `init` is called! Mutex { inner: UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER) } } #[inline] |
