Skip to content

Commit 5533da2

Browse files
authored
Merge pull request #4223 from Stypox/ctrl-c-backtrace
Show interpreter backtrace error on Ctrl+C
2 parents a3ea86e + 5cf0c95 commit 5533da2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/tools/miri/src/concurrency/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
11501150
loop {
11511151
if CTRL_C_RECEIVED.load(Relaxed) {
11521152
this.machine.handle_abnormal_termination();
1153-
std::process::exit(1);
1153+
throw_machine_stop!(TerminationInfo::Interrupted);
11541154
}
11551155
match this.machine.threads.schedule(&this.machine.clock)? {
11561156
SchedulingAction::ExecuteStep => {

src/tools/miri/src/diagnostics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ pub enum TerminationInfo {
1616
leak_check: bool,
1717
},
1818
Abort(String),
19+
/// Miri was interrupted by a Ctrl+C from the user
20+
Interrupted,
1921
UnsupportedInIsolation(String),
2022
StackedBorrowsUb {
2123
msg: String,
@@ -63,6 +65,7 @@ impl fmt::Display for TerminationInfo {
6365
match self {
6466
Exit { code, .. } => write!(f, "the evaluated program completed with exit code {code}"),
6567
Abort(msg) => write!(f, "{msg}"),
68+
Interrupted => write!(f, "interpretation was interrupted"),
6669
UnsupportedInIsolation(msg) => write!(f, "{msg}"),
6770
Int2PtrWithStrictProvenance =>
6871
write!(
@@ -226,6 +229,7 @@ pub fn report_error<'tcx>(
226229
let title = match info {
227230
&Exit { code, leak_check } => return Some((code, leak_check)),
228231
Abort(_) => Some("abnormal termination"),
232+
Interrupted => None,
229233
UnsupportedInIsolation(_) | Int2PtrWithStrictProvenance | UnsupportedForeignItem(_) =>
230234
Some("unsupported operation"),
231235
StackedBorrowsUb { .. } | TreeBorrowsUb { .. } | DataRace { .. } =>

0 commit comments

Comments
 (0)