Skip to content

Commit

Permalink
Auto merge of #16652 - davidbarsky:david/deadlock-fix-for-16643, r=Ve…
Browse files Browse the repository at this point in the history
…ykril

internal: fix deadlock introduced by #16643

This fixes a deadlock introduced by #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)
  • Loading branch information
bors committed Feb 23, 2024
2 parents 1214404 + 6477973 commit 03b3cb6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/salsa/src/derived.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,14 @@ where
revision: Revision,
) -> bool {
debug_assert!(revision < db.salsa_runtime().current_revision());
let read = &self.slot_map.read();
let read = self.slot_map.read();
let Some((key, slot)) = read.get_index(index as usize) else {
return false;
};
slot.maybe_changed_after(db, revision, key)
let (key, slot) = (key.clone(), slot.clone());
// note: this drop is load-bearing. removing it would causes deadlocks.
drop(read);
slot.maybe_changed_after(db, revision, &key)
}

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

0 comments on commit 03b3cb6

Please sign in to comment.