|
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 log::trace;
|
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;
|
@@ -1013,21 +1014,22 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
1013 | 1014 | /// Run the core interpreter loop. Returns only when an interrupt occurs (an error or program
|
1014 | 1015 | /// termination).
|
1015 | 1016 | fn run_threads(&mut self) -> InterpResult<'tcx, !> {
|
1016 |
| - static SIGNALED: AtomicBool = AtomicBool::new(false); |
| 1017 | + // In normal rustc, rustc_driver::main installs this handler. But we don't use that |
| 1018 | + // function, see src/bin/miri.rs. |
1017 | 1019 | ctrlc::set_handler(move || {
|
1018 |
| - // Indicate that we have ben signaled to stop. If we were already signaled, exit |
| 1020 | + // Indicate that we have been signaled to stop. If we were already signaled, exit |
1019 | 1021 | // immediately. In our interpreter loop we try to consult this value often, but if for
|
1020 | 1022 | // whatever reason we don't get to that check or the cleanup we do upon finding that
|
1021 | 1023 | // this bool has become true takes a long time, the exit here will promptly exit the
|
1022 | 1024 | // process on the second Ctrl-C.
|
1023 |
| - if SIGNALED.swap(true, Relaxed) { |
| 1025 | + if CTRL_C_RECEIVED.swap(true, Relaxed) { |
1024 | 1026 | std::process::exit(1);
|
1025 | 1027 | }
|
1026 | 1028 | })
|
1027 |
| - .unwrap(); |
| 1029 | + .expect("Unable to install ctrlc handler"); |
1028 | 1030 | let this = self.eval_context_mut();
|
1029 | 1031 | loop {
|
1030 |
| - if SIGNALED.load(Relaxed) { |
| 1032 | + if CTRL_C_RECEIVED.load(Relaxed) { |
1031 | 1033 | this.machine.handle_abnormal_termination();
|
1032 | 1034 | std::process::exit(1);
|
1033 | 1035 | }
|
|
0 commit comments