diff options
| author | Ralf Jung <post@ralfj.de> | 2025-03-07 12:02:08 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-07 12:02:08 +0000 |
| commit | 5533da2d9f628c161598c74901c2740689d9a2df (patch) | |
| tree | 603a1d2890a547504019c4829fa73b1429428b05 | |
| parent | a3ea86e4b1e3a668f74c8fb7eaf99e97db047950 (diff) | |
| parent | 5cf0c95552a8400046cfe00afd0d6e8c3970fa10 (diff) | |
| download | rust-5533da2d9f628c161598c74901c2740689d9a2df.tar.gz rust-5533da2d9f628c161598c74901c2740689d9a2df.zip | |
Merge pull request #4223 from Stypox/ctrl-c-backtrace
Show interpreter backtrace error on Ctrl+C
| -rw-r--r-- | src/tools/miri/src/concurrency/thread.rs | 2 | ||||
| -rw-r--r-- | src/tools/miri/src/diagnostics.rs | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/tools/miri/src/concurrency/thread.rs b/src/tools/miri/src/concurrency/thread.rs index a8a2491304d..94629964ea6 100644 --- a/src/tools/miri/src/concurrency/thread.rs +++ b/src/tools/miri/src/concurrency/thread.rs @@ -1150,7 +1150,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { loop { if CTRL_C_RECEIVED.load(Relaxed) { this.machine.handle_abnormal_termination(); - std::process::exit(1); + throw_machine_stop!(TerminationInfo::Interrupted); } match this.machine.threads.schedule(&this.machine.clock)? { SchedulingAction::ExecuteStep => { diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs index 1a12d4139c7..014b1299f2d 100644 --- a/src/tools/miri/src/diagnostics.rs +++ b/src/tools/miri/src/diagnostics.rs @@ -16,6 +16,8 @@ pub enum TerminationInfo { leak_check: bool, }, Abort(String), + /// Miri was interrupted by a Ctrl+C from the user + Interrupted, UnsupportedInIsolation(String), StackedBorrowsUb { msg: String, @@ -63,6 +65,7 @@ impl fmt::Display for TerminationInfo { match self { Exit { code, .. } => write!(f, "the evaluated program completed with exit code {code}"), Abort(msg) => write!(f, "{msg}"), + Interrupted => write!(f, "interpretation was interrupted"), UnsupportedInIsolation(msg) => write!(f, "{msg}"), Int2PtrWithStrictProvenance => write!( @@ -226,6 +229,7 @@ pub fn report_error<'tcx>( let title = match info { &Exit { code, leak_check } => return Some((code, leak_check)), Abort(_) => Some("abnormal termination"), + Interrupted => None, UnsupportedInIsolation(_) | Int2PtrWithStrictProvenance | UnsupportedForeignItem(_) => Some("unsupported operation"), StackedBorrowsUb { .. } | TreeBorrowsUb { .. } | DataRace { .. } => |
