|
3 | 3 | use std::cell::RefCell; |
4 | 4 | use std::collections::hash_map::Entry; |
5 | 5 | use std::num::TryFromIntError; |
6 | | -use std::sync::atomic::{AtomicBool, Ordering::Relaxed}; |
| 6 | +use std::sync::atomic::Ordering::Relaxed; |
7 | 7 | use std::task::Poll; |
8 | 8 | use std::time::{Duration, SystemTime}; |
9 | 9 |
|
10 | 10 | use either::Either; |
11 | 11 |
|
12 | 12 | use rustc_data_structures::fx::FxHashMap; |
| 13 | +use rustc_data_structures::CTRL_C_RECEIVED; |
13 | 14 | use rustc_hir::def_id::DefId; |
14 | 15 | use rustc_index::{Idx, IndexVec}; |
15 | 16 | use rustc_middle::mir::Mutability; |
@@ -1045,21 +1046,22 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { |
1045 | 1046 | /// Run the core interpreter loop. Returns only when an interrupt occurs (an error or program |
1046 | 1047 | /// termination). |
1047 | 1048 | fn run_threads(&mut self) -> InterpResult<'tcx, !> { |
1048 | | - static SIGNALED: AtomicBool = AtomicBool::new(false); |
| 1049 | + // In normal rustc, rustc_driver::main installs this handler. But we don't use that |
| 1050 | + // function, see src/bin/miri.rs. |
1049 | 1051 | ctrlc::set_handler(move || { |
1050 | | - // Indicate that we have ben signaled to stop. If we were already signaled, exit |
| 1052 | + // Indicate that we have been signaled to stop. If we were already signaled, exit |
1051 | 1053 | // immediately. In our interpreter loop we try to consult this value often, but if for |
1052 | 1054 | // whatever reason we don't get to that check or the cleanup we do upon finding that |
1053 | 1055 | // this bool has become true takes a long time, the exit here will promptly exit the |
1054 | 1056 | // process on the second Ctrl-C. |
1055 | | - if SIGNALED.swap(true, Relaxed) { |
| 1057 | + if CTRL_C_RECEIVED.swap(true, Relaxed) { |
1056 | 1058 | std::process::exit(1); |
1057 | 1059 | } |
1058 | 1060 | }) |
1059 | | - .unwrap(); |
| 1061 | + .expect("Unable to install ctrlc handler"); |
1060 | 1062 | let this = self.eval_context_mut(); |
1061 | 1063 | loop { |
1062 | | - if SIGNALED.load(Relaxed) { |
| 1064 | + if CTRL_C_RECEIVED.load(Relaxed) { |
1063 | 1065 | this.machine.handle_abnormal_termination(); |
1064 | 1066 | std::process::exit(1); |
1065 | 1067 | } |
|
0 commit comments