]> git.lizzy.rs Git - rust.git/commitdiff
Fix a race condition
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Sun, 2 Dec 2018 20:57:47 +0000 (21:57 +0100)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Thu, 6 Dec 2018 22:18:06 +0000 (23:18 +0100)
src/librustc/ty/query/job.rs

index d5bf3856bc43256240ee5d4e3a3a2515d9714285..1439e41bb31fd9ba5924683d19947288f657be9a 100644 (file)
@@ -103,8 +103,11 @@ pub(super) fn await<'lcx>(
                     condvar: Condvar::new(),
                 });
                 self.latch.await(&waiter);
-
-                match Lrc::get_mut(&mut waiter).unwrap().cycle.get_mut().take() {
+                // FIXME: Get rid of this lock. We have ownership of the QueryWaiter
+                // although another thread may still have a Lrc reference so we cannot
+                // use Lrc::get_mut
+                let mut cycle = waiter.cycle.lock();
+                match cycle.take() {
                     None => Ok(()),
                     Some(cycle) => Err(cycle)
                 }