File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,15 @@ impl Mutex {
3030 // a type of PTHREAD_MUTEX_DEFAULT, which has undefined behavior if you
3131 // try to re-lock it from the same thread when you already hold a lock
3232 // (https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html).
33+ // This is the case even if PTHREAD_MUTEX_DEFAULT == PTHREAD_MUTEX_NORMAL
34+ // (https://github.com/rust-lang/rust/issues/33770#issuecomment-220847521) -- in that
35+ // case, `pthread_mutexattr_settype(PTHREAD_MUTEX_DEFAULT)` will of course be the same
36+ // as setting it to `PTHREAD_MUTEX_NORMAL`, but not setting any mode will result in
37+ // a Mutex where re-locking is UB.
3338 //
3439 // In practice, glibc takes advantage of this undefined behavior to
3540 // implement hardware lock elision, which uses hardware transactional
36- // memory to avoid acquiring the lock.
37- // This is the case even if PTHREAD_MUTEX_DEFAULT == PTHREAD_MUTEX_NORMAL
38- // (https://github.com/rust-lang/rust/issues/33770#issuecomment-220847521).
39- // As a consequence, while a transaction is in
41+ // memory to avoid acquiring the lock. While a transaction is in
4042 // progress, the lock appears to be unlocked. This isn't a problem for
4143 // other threads since the transactional memory will abort if a conflict
4244 // is detected, however no abort is generated when re-locking from the
You can’t perform that action at this time.
0 commit comments