]> git.lizzy.rs Git - rust.git/blobdiff - src/thread.rs
Auto merge of #1772 - RalfJung:less-timeout-checking, r=RalfJung
[rust.git] / src / thread.rs
index 0f373e4cd31eb15cd25e38b1de365fce152776a7..8b1787132cbcca7414d53f1111c601325c2afae9 100644 (file)
@@ -711,7 +711,17 @@ fn unregister_timeout_callback_if_exists(&mut self, thread: ThreadId) {
     fn run_timeout_callback(&mut self) -> InterpResult<'tcx> {
         let this = self.eval_context_mut();
         let (thread, callback) =
-            this.machine.threads.get_ready_callback().expect("no callback found");
+            if let Some((thread, callback)) = this.machine.threads.get_ready_callback() {
+                (thread, callback)
+            } else {
+                // get_ready_callback can return None if the computer's clock
+                // was shifted after calling the scheduler and before the call
+                // to get_ready_callback (see issue
+                // https://github.com/rust-lang/miri/issues/1763). In this case,
+                // just do nothing, which effectively just returns to the
+                // scheduler.
+                return Ok(());
+            };
         // This back-and-forth with `set_active_thread` is here because of two
         // design decisions:
         // 1. Make the caller and not the callback responsible for changing