Skip to content

Commit 03b3cb6

Browse files
committed
Auto merge of rust-lang#16652 - davidbarsky:david/deadlock-fix-for-16643, r=Veykril
internal: fix deadlock introduced by rust-lang#16643 This fixes a deadlock introduced by rust-lang#16643 ([backtrace](https://gist.github.com/davidbarsky/00f17598f5496a9c41aff31fec1c42d6)). `maybe_changed_after` calls back into other queries, so the cloning here is unfortunately inevitable. (Zulip conversation: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Fixing.20proc-macro.20dirtying.20with.20unindexed.20projects)
2 parents 1214404 + 6477973 commit 03b3cb6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

crates/salsa/src/derived.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,14 @@ where
146146
revision: Revision,
147147
) -> bool {
148148
debug_assert!(revision < db.salsa_runtime().current_revision());
149-
let read = &self.slot_map.read();
149+
let read = self.slot_map.read();
150150
let Some((key, slot)) = read.get_index(index as usize) else {
151151
return false;
152152
};
153-
slot.maybe_changed_after(db, revision, key)
153+
let (key, slot) = (key.clone(), slot.clone());
154+
// note: this drop is load-bearing. removing it would causes deadlocks.
155+
drop(read);
156+
slot.maybe_changed_after(db, revision, &key)
154157
}
155158

156159
fn fetch(&self, db: &<Q as QueryDb<'_>>::DynDb, key: &Q::Key) -> Q::Value {

0 commit comments

Comments
 (0)