File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,15 @@ impl Mutex {
30
30
// a type of PTHREAD_MUTEX_DEFAULT, which has undefined behavior if you
31
31
// try to re-lock it from the same thread when you already hold a lock
32
32
// (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.
33
38
//
34
39
// In practice, glibc takes advantage of this undefined behavior to
35
40
// 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
40
42
// progress, the lock appears to be unlocked. This isn't a problem for
41
43
// other threads since the transactional memory will abort if a conflict
42
44
// is detected, however no abort is generated when re-locking from the
You can’t perform that action at this time.
0 commit comments