You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expand lockorder testing to look at mutexes, not specific instances
Our existing lockorder inversion checks look at specific instances
of mutexes rather than the general mutex itself. This changes that
behavior to look at the instruction pointer at which a mutex was
created and treat all mutexes which were created at the same
location as equivalent.
This allows us to detect lockorder inversions which occur across
tests, though it does substantially reduce parallelism during test
runs.
// Returns whether we were a recursive lock (only relevant for read)
@@ -89,18 +133,25 @@ impl LockMetadata {
89
133
}
90
134
for locked in held.borrow().iter(){
91
135
if !read && *locked == *this {
92
-
panic!("Tried to lock a lock while it was held!");
136
+
// With `feature = "backtrace"` set, we may be looking at different instances
137
+
// of the same lock.
138
+
debug_assert!(cfg!(feature = "backtrace"),"Tried to lock a lock while it was held!");
93
139
}
94
140
for locked_dep in locked.locked_before.lock().unwrap().iter(){
95
-
if*locked_dep == *this {
141
+
if locked_dep.lock == *this && locked_dep.lock != *locked{
96
142
#[cfg(feature = "backtrace")]
97
-
panic!("Tried to violate existing lockorder.\nMutex that should be locked after the current lock was created at the following backtrace.\nNote that to get a backtrace for the lockorder violation, you should set RUST_BACKTRACE=1\n{:?}", locked.lock_construction_bt);
143
+
panic!("Tried to violate existing lockorder.\nMutex that should be locked after the current lock was created at the following backtrace.\nNote that to get a backtrace for the lockorder violation, you should set RUST_BACKTRACE=1\nLock constructed at:\n{:?}\n\nLock dep created at:\n{:?}\n\n", locked.lock_construction_bt, locked_dep.lockdep_trace);
98
144
#[cfg(not(feature = "backtrace"))]
99
145
panic!("Tried to violate existing lockorder. Build with the backtrace feature for more info.");
100
146
}
101
147
}
102
148
// Insert any already-held locks in our locked-before set.
0 commit comments