From 8a36d12d3664ab0e882ce98bacd6f7f95000f6a2 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 29 Nov 2019 10:16:03 +0100 Subject: [PATCH 01/12] implement proper panicking for failed index check --- src/lib.rs | 3 ++- src/machine.rs | 10 ++++++++++ src/shims/panic.rs | 40 +++++++++++++++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 05234e880f..abed7ab9df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,6 +38,7 @@ pub use crate::shims::dlsym::{Dlsym, EvalContextExt as DlsymEvalContextExt}; pub use crate::shims::env::{EnvVars, EvalContextExt as EnvEvalContextExt}; pub use crate::shims::fs::{FileHandler, EvalContextExt as FileEvalContextExt}; pub use crate::shims::panic::{CatchUnwindData, EvalContextExt as PanicEvalContextExt}; + pub use crate::operator::EvalContextExt as OperatorEvalContextExt; pub use crate::range_map::RangeMap; pub use crate::helpers::{EvalContextExt as HelpersEvalContextExt}; @@ -45,7 +46,7 @@ pub use crate::mono_hash_map::MonoHashMap; pub use crate::stacked_borrows::{EvalContextExt as StackedBorEvalContextExt, Tag, Permission, Stack, Stacks, Item}; pub use crate::machine::{ PAGE_SIZE, STACK_ADDR, STACK_SIZE, NUM_CPUS, - MemoryExtra, AllocExtra, MiriMemoryKind, Evaluator, MiriEvalContext, MiriEvalContextExt, + MemoryExtra, AllocExtra, FrameData, MiriMemoryKind, Evaluator, MiriEvalContext, MiriEvalContextExt, }; pub use crate::eval::{eval_main, create_ecx, MiriConfig, TerminationInfo}; diff --git a/src/machine.rs b/src/machine.rs index 94ddee6fc0..07864ac4ee 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -215,6 +215,16 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> { ecx.call_intrinsic(span, instance, args, ret, unwind) } + #[inline(always)] + fn assert_panic( + ecx: &mut InterpCx<'mir, 'tcx, Self>, + span: Span, + msg: &AssertMessage<'tcx>, + unwind: Option, + ) -> InterpResult<'tcx> { + ecx.assert_panic(span, msg, unwind) + } + #[inline(always)] fn binary_ptr_op( ecx: &rustc_mir::interpret::InterpCx<'mir, 'tcx, Self>, diff --git a/src/shims/panic.rs b/src/shims/panic.rs index 6cc9f176c8..4b9cb6b419 100644 --- a/src/shims/panic.rs +++ b/src/shims/panic.rs @@ -11,11 +11,12 @@ //! gets popped *during unwinding*, we take the panic payload and store it according to the extra //! metadata we remembered when pushing said frame. +use syntax::source_map::Span; use rustc::mir; -use crate::*; -use super::machine::FrameData; +use rustc::ty::{self, layout::LayoutOf}; use rustc_target::spec::PanicStrategy; -use crate::rustc_target::abi::LayoutOf; + +use crate::*; /// Holds all of the relevant data for a call to /// `__rust_maybe_catch_panic`. @@ -150,4 +151,37 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx this.memory.extra.stacked_borrows.borrow_mut().end_call(extra.call_id); Ok(res) } + + fn assert_panic( + &mut self, + span: Span, + msg: &AssertMessage<'tcx>, + unwind: Option, + ) -> InterpResult<'tcx> { + use rustc::mir::interpret::PanicInfo::*; + let this = self.eval_context_mut(); + + match msg { + BoundsCheck { ref index, ref len } => { + // First arg: Caller location. + let location = this.alloc_caller_location_for_span(span)?; + // Second arg: index. + let index = this.read_scalar(this.eval_operand(index, None)?)?; + // Third arg: len. + let len = this.read_scalar(this.eval_operand(len, None)?)?; + + // Call the lang item. + let panic_bounds_check = this.tcx.lang_items().panic_bounds_check_fn().unwrap(); + let panic_bounds_check = ty::Instance::mono(this.tcx.tcx, panic_bounds_check); + this.call_function( + panic_bounds_check, + &[location.ptr, index.not_undef()?, len.not_undef()?], + None, + StackPopCleanup::Goto { ret: None, unwind }, + )?; + } + _ => unimplemented!() + } + Ok(()) + } } From b91383b068dcd8c7cb287858e781c80323601fa5 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 29 Nov 2019 11:17:44 +0100 Subject: [PATCH 02/12] implement proper panicking for other MIR assertions Requires generalizing the call_function helper to arbitrary Immediate arguments --- src/eval.rs | 4 ++-- src/helpers.rs | 4 ++-- src/machine.rs | 2 +- src/shims/env.rs | 2 +- src/shims/foreign_items.rs | 8 ++++---- src/shims/panic.rs | 27 ++++++++++++++++++++++++--- src/shims/tls.rs | 2 +- 7 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/eval.rs b/src/eval.rs index dbb14b7bb1..f13ef89ff7 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -103,7 +103,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Env.into()); for (idx, arg) in argvs.into_iter().enumerate() { let place = ecx.mplace_field(argvs_place, idx as u64)?; - ecx.write_scalar(Scalar::Ptr(arg), place.into())?; + ecx.write_scalar(arg, place.into())?; } ecx.memory .mark_immutable(argvs_place.ptr.assert_ptr().alloc_id)?; @@ -149,7 +149,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( // Call start function. ecx.call_function( start_instance, - &[main_ptr.into(), argc, argv], + &[main_ptr.into(), argc.into(), argv.into()], Some(ret_place.into()), StackPopCleanup::None { cleanup: true }, )?; diff --git a/src/helpers.rs b/src/helpers.rs index 28c31a07ef..68ce014c30 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -124,7 +124,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx fn call_function( &mut self, f: ty::Instance<'tcx>, - args: &[Scalar], + args: &[Immediate], dest: Option>, stack_pop: StackPopCleanup, ) -> InterpResult<'tcx> { @@ -146,7 +146,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx let callee_arg = this.local_place( callee_args.next().expect("callee has fewer arguments than expected") )?; - this.write_scalar(*arg, callee_arg)?; + this.write_immediate(*arg, callee_arg)?; } callee_args.next().expect_none("callee has more arguments than expected"); diff --git a/src/machine.rs b/src/machine.rs index 07864ac4ee..980c6115e9 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -253,7 +253,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> { let malloc = ty::Instance::mono(ecx.tcx.tcx, malloc); ecx.call_function( malloc, - &[size, align], + &[size.into(), align.into()], Some(dest), // Don't do anything when we are done. The `statement()` function will increment // the old stack frame's stmt counter to the next statement, which means that when diff --git a/src/shims/env.rs b/src/shims/env.rs index 44896fd9bb..ae8dae0313 100644 --- a/src/shims/env.rs +++ b/src/shims/env.rs @@ -57,7 +57,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx Ok(match this.machine.env_vars.map.get(name) { // The offset is used to strip the "{name}=" part of the string. Some(var_ptr) => { - Scalar::Ptr(var_ptr.offset(Size::from_bytes(name.len() as u64 + 1), this)?) + Scalar::from(var_ptr.offset(Size::from_bytes(name.len() as u64 + 1), this)?) } None => Scalar::ptr_null(&*this.tcx), }) diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index 114931e435..f27b4fb333 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -205,7 +205,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx Align::from_bytes(align).unwrap(), MiriMemoryKind::C.into(), ); - this.write_scalar(Scalar::Ptr(ptr), ret.into())?; + this.write_scalar(ptr, ret.into())?; } this.write_null(dest)?; } @@ -234,7 +234,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx Align::from_bytes(align).unwrap(), MiriMemoryKind::Rust.into(), ); - this.write_scalar(Scalar::Ptr(ptr), dest)?; + this.write_scalar(ptr, dest)?; } "__rust_alloc_zeroed" => { let size = this.read_scalar(args[0])?.to_machine_usize(this)?; @@ -254,7 +254,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx this.memory .write_bytes(ptr.into(), iter::repeat(0u8).take(size as usize)) .unwrap(); - this.write_scalar(Scalar::Ptr(ptr), dest)?; + this.write_scalar(ptr, dest)?; } "__rust_dealloc" => { let ptr = this.read_scalar(args[0])?.not_undef()?; @@ -295,7 +295,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx align, MiriMemoryKind::Rust.into(), )?; - this.write_scalar(Scalar::Ptr(new_ptr), dest)?; + this.write_scalar(new_ptr, dest)?; } "syscall" => { diff --git a/src/shims/panic.rs b/src/shims/panic.rs index 4b9cb6b419..7cdd81d935 100644 --- a/src/shims/panic.rs +++ b/src/shims/panic.rs @@ -86,7 +86,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx MPlaceTy::dangling(this.layout_of(tcx.mk_unit())?, this).into(); this.call_function( f_instance, - &[f_arg], + &[f_arg.into()], Some(ret_place), // Directly return to caller. StackPopCleanup::Goto { ret: Some(ret), unwind: None }, @@ -163,6 +163,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx match msg { BoundsCheck { ref index, ref len } => { + // Forward to `panic_bounds_check` lang item. + // First arg: Caller location. let location = this.alloc_caller_location_for_span(span)?; // Second arg: index. @@ -175,12 +177,31 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx let panic_bounds_check = ty::Instance::mono(this.tcx.tcx, panic_bounds_check); this.call_function( panic_bounds_check, - &[location.ptr, index.not_undef()?, len.not_undef()?], + &[location.ptr.into(), index.into(), len.into()], + None, + StackPopCleanup::Goto { ret: None, unwind }, + )?; + } + _ => { + // Forward everything else to `panic` lang item. + + // First arg: Message. + let msg = msg.description(); + let msg = this.allocate_str(msg, MiriMemoryKind::Static.into()); + + // Second arg: Caller location. + let location = this.alloc_caller_location_for_span(span)?; + + // Call the lang item. + let panic = this.tcx.lang_items().panic_fn().unwrap(); + let panic = ty::Instance::mono(this.tcx.tcx, panic); + this.call_function( + panic, + &[msg.to_ref(), location.ptr.into()], None, StackPopCleanup::Goto { ret: None, unwind }, )?; } - _ => unimplemented!() } Ok(()) } diff --git a/src/shims/tls.rs b/src/shims/tls.rs index ea8b0df230..420fd63a61 100644 --- a/src/shims/tls.rs +++ b/src/shims/tls.rs @@ -150,7 +150,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx let ret_place = MPlaceTy::dangling(this.layout_of(this.tcx.mk_unit())?, this).into(); this.call_function( instance, - &[ptr], + &[ptr.into()], Some(ret_place), StackPopCleanup::None { cleanup: true }, )?; From 4cf83433b1fb17e3d08fe68a12ee58c7960330cc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 29 Nov 2019 11:19:15 +0100 Subject: [PATCH 03/12] test built-in panic catching --- tests/run-pass/catch_panic.rs | 8 ++++++++ tests/run-pass/catch_panic.stderr | 18 +++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/run-pass/catch_panic.rs b/tests/run-pass/catch_panic.rs index 4c8b4cba90..a14dd411c1 100644 --- a/tests/run-pass/catch_panic.rs +++ b/tests/run-pass/catch_panic.rs @@ -1,4 +1,6 @@ // ignore-windows: Unwind panicking does not currently work on Windows +#![allow(const_err)] + use std::panic::{catch_unwind, AssertUnwindSafe}; use std::cell::Cell; @@ -44,15 +46,21 @@ fn main() { prev(panic_info) })); + // Std panics test(|_old_val| std::panic!("Hello from panic: std")); test(|old_val| std::panic!(format!("Hello from panic: {:?}", old_val))); test(|old_val| std::panic!("Hello from panic: {:?}", old_val)); test(|_old_val| std::panic!(1337)); + // Core panics test(|_old_val| core::panic!("Hello from panic: core")); test(|old_val| core::panic!(&format!("Hello from panic: {:?}", old_val))); test(|old_val| core::panic!("Hello from panic: {:?}", old_val)); + // Built-in panics + test(|_old_val| { let _val = [0, 1, 2][4]; loop {} }); + test(|_old_val| { let _val = 1/0; loop {} }); + // Cleanup: reset to default hook. drop(std::panic::take_hook()); diff --git a/tests/run-pass/catch_panic.stderr b/tests/run-pass/catch_panic.stderr index be729005dd..fd9a2f14ec 100644 --- a/tests/run-pass/catch_panic.stderr +++ b/tests/run-pass/catch_panic.stderr @@ -1,15 +1,19 @@ -thread 'main' panicked at 'Hello from panic: std', $DIR/catch_panic.rs:47:21 +thread 'main' panicked at 'Hello from panic: std', $DIR/catch_panic.rs:50:21 Caught panic message (&str): Hello from panic: std -thread 'main' panicked at 'Hello from panic: 1', $DIR/catch_panic.rs:48:20 +thread 'main' panicked at 'Hello from panic: 1', $DIR/catch_panic.rs:51:20 Caught panic message (String): Hello from panic: 1 -thread 'main' panicked at 'Hello from panic: 2', $DIR/catch_panic.rs:49:20 +thread 'main' panicked at 'Hello from panic: 2', $DIR/catch_panic.rs:52:20 Caught panic message (String): Hello from panic: 2 -thread 'main' panicked at 'Box', $DIR/catch_panic.rs:50:21 +thread 'main' panicked at 'Box', $DIR/catch_panic.rs:53:21 Failed get caught panic message. -thread 'main' panicked at 'Hello from panic: core', $DIR/catch_panic.rs:52:21 +thread 'main' panicked at 'Hello from panic: core', $DIR/catch_panic.rs:56:21 Caught panic message (String): Hello from panic: core -thread 'main' panicked at 'Hello from panic: 5', $DIR/catch_panic.rs:53:20 +thread 'main' panicked at 'Hello from panic: 5', $DIR/catch_panic.rs:57:20 Caught panic message (String): Hello from panic: 5 -thread 'main' panicked at 'Hello from panic: 6', $DIR/catch_panic.rs:54:20 +thread 'main' panicked at 'Hello from panic: 6', $DIR/catch_panic.rs:58:20 Caught panic message (String): Hello from panic: 6 +thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4', $DIR/catch_panic.rs:61:34 +Caught panic message (String): index out of bounds: the len is 3 but the index is 4 +thread 'main' panicked at 'attempt to divide by zero', $DIR/catch_panic.rs:62:34 +Caught panic message (String): attempt to divide by zero Success! From b2cddd27bd1ba25f20cb5608d73053170f2ed83b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 29 Nov 2019 11:52:53 +0100 Subject: [PATCH 04/12] better span for functions whose frame we push 'manually' --- src/eval.rs | 7 +------ src/helpers.rs | 6 +++++- src/shims/panic.rs | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/eval.rs b/src/eval.rs index f13ef89ff7..33bcfcc738 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -221,12 +221,7 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) -> }; e.print_backtrace(); if let Some(frame) = ecx.stack().last() { - let block = &frame.body.basic_blocks()[frame.block.unwrap()]; - let span = if frame.stmt < block.statements.len() { - block.statements[frame.stmt].source_info.span - } else { - block.terminator().source_info.span - }; + let span = frame.current_source_info().unwrap().span; let msg = format!("Miri evaluation error: {}", msg); let mut err = ecx.tcx.sess.struct_span_err(span, msg.as_str()); diff --git a/src/helpers.rs b/src/helpers.rs index 68ce014c30..7bd29e1741 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -132,9 +132,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx // Push frame. let mir = this.load_mir(f.def, None)?; + let span = this.stack().last() + .and_then(Frame::current_source_info) + .map(|si| si.span) + .unwrap_or(DUMMY_SP); this.push_stack_frame( f, - DUMMY_SP, // There is no call site. + span, mir, dest, stack_pop, diff --git a/src/shims/panic.rs b/src/shims/panic.rs index 7cdd81d935..3e82519f86 100644 --- a/src/shims/panic.rs +++ b/src/shims/panic.rs @@ -166,7 +166,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx // Forward to `panic_bounds_check` lang item. // First arg: Caller location. - let location = this.alloc_caller_location_for_span(span)?; + let location = this.alloc_caller_location_for_span(span); // Second arg: index. let index = this.read_scalar(this.eval_operand(index, None)?)?; // Third arg: len. @@ -190,7 +190,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx let msg = this.allocate_str(msg, MiriMemoryKind::Static.into()); // Second arg: Caller location. - let location = this.alloc_caller_location_for_span(span)?; + let location = this.alloc_caller_location_for_span(span); // Call the lang item. let panic = this.tcx.lang_items().panic_fn().unwrap(); From ae53b1222a1cbb21b057e294ea93f1283210fb1a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 29 Nov 2019 13:18:54 +0100 Subject: [PATCH 05/12] fix and expand panic tests --- tests/compile-fail/div-by-zero-2.rs | 5 ----- tests/compile-fail/overflowing-lsh-neg.rs | 6 ------ tests/compile-fail/overflowing-rsh-1.rs | 5 ----- tests/compile-fail/{ => panic}/panic_abort1.rs | 0 tests/compile-fail/{ => panic}/panic_abort2.rs | 0 tests/compile-fail/{ => panic}/panic_abort3.rs | 0 tests/compile-fail/{ => panic}/panic_abort4.rs | 0 tests/run-pass/{ => panic}/catch_panic.rs | 0 tests/run-pass/{ => panic}/catch_panic.stderr | 0 tests/run-pass/panic/div-by-zero-2.rs | 6 ++++++ tests/run-pass/panic/div-by-zero-2.stderr | 1 + tests/run-pass/panic/overflowing-lsh-neg.rs | 7 +++++++ tests/run-pass/panic/overflowing-lsh-neg.stderr | 1 + tests/run-pass/panic/overflowing-rsh-1.rs | 6 ++++++ tests/run-pass/panic/overflowing-rsh-1.stderr | 1 + .../{compile-fail => run-pass/panic}/overflowing-rsh-2.rs | 3 ++- tests/run-pass/panic/overflowing-rsh-2.stderr | 1 + tests/run-pass/panic/panic1.rs | 4 ++++ tests/run-pass/panic/panic1.stderr | 1 + tests/run-pass/panic/panic2.rs | 4 ++++ tests/run-pass/panic/panic2.stderr | 1 + tests/run-pass/panic/panic3.rs | 4 ++++ tests/run-pass/panic/panic3.stderr | 1 + tests/run-pass/panic/panic4.rs | 4 ++++ tests/run-pass/panic/panic4.stderr | 1 + tests/{compile-fail => run-pass/panic}/transmute_fat2.rs | 2 +- tests/run-pass/panic/transmute_fat2.stderr | 1 + 27 files changed, 47 insertions(+), 18 deletions(-) delete mode 100644 tests/compile-fail/div-by-zero-2.rs delete mode 100644 tests/compile-fail/overflowing-lsh-neg.rs delete mode 100644 tests/compile-fail/overflowing-rsh-1.rs rename tests/compile-fail/{ => panic}/panic_abort1.rs (100%) rename tests/compile-fail/{ => panic}/panic_abort2.rs (100%) rename tests/compile-fail/{ => panic}/panic_abort3.rs (100%) rename tests/compile-fail/{ => panic}/panic_abort4.rs (100%) rename tests/run-pass/{ => panic}/catch_panic.rs (100%) rename tests/run-pass/{ => panic}/catch_panic.stderr (100%) create mode 100644 tests/run-pass/panic/div-by-zero-2.rs create mode 100644 tests/run-pass/panic/div-by-zero-2.stderr create mode 100644 tests/run-pass/panic/overflowing-lsh-neg.rs create mode 100644 tests/run-pass/panic/overflowing-lsh-neg.stderr create mode 100644 tests/run-pass/panic/overflowing-rsh-1.rs create mode 100644 tests/run-pass/panic/overflowing-rsh-1.stderr rename tests/{compile-fail => run-pass/panic}/overflowing-rsh-2.rs (54%) create mode 100644 tests/run-pass/panic/overflowing-rsh-2.stderr create mode 100644 tests/run-pass/panic/panic1.rs create mode 100644 tests/run-pass/panic/panic1.stderr create mode 100644 tests/run-pass/panic/panic2.rs create mode 100644 tests/run-pass/panic/panic2.stderr create mode 100644 tests/run-pass/panic/panic3.rs create mode 100644 tests/run-pass/panic/panic3.stderr create mode 100644 tests/run-pass/panic/panic4.rs create mode 100644 tests/run-pass/panic/panic4.stderr rename tests/{compile-fail => run-pass/panic}/transmute_fat2.rs (76%) create mode 100644 tests/run-pass/panic/transmute_fat2.stderr diff --git a/tests/compile-fail/div-by-zero-2.rs b/tests/compile-fail/div-by-zero-2.rs deleted file mode 100644 index 302d26a41f..0000000000 --- a/tests/compile-fail/div-by-zero-2.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![allow(const_err)] - -fn main() { - let _n = 1 / 0; //~ ERROR attempt to divide by zero -} diff --git a/tests/compile-fail/overflowing-lsh-neg.rs b/tests/compile-fail/overflowing-lsh-neg.rs deleted file mode 100644 index 253294d1f5..0000000000 --- a/tests/compile-fail/overflowing-lsh-neg.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![allow(exceeding_bitshifts)] -#![allow(const_err)] - -fn main() { - let _n = 2i64 << -1; //~ ERROR attempt to shift left with overflow -} diff --git a/tests/compile-fail/overflowing-rsh-1.rs b/tests/compile-fail/overflowing-rsh-1.rs deleted file mode 100644 index e0d3f1904a..0000000000 --- a/tests/compile-fail/overflowing-rsh-1.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![allow(exceeding_bitshifts, const_err)] - -fn main() { - let _n = 1i64 >> 64; //~ ERROR attempt to shift right with overflow -} diff --git a/tests/compile-fail/panic_abort1.rs b/tests/compile-fail/panic/panic_abort1.rs similarity index 100% rename from tests/compile-fail/panic_abort1.rs rename to tests/compile-fail/panic/panic_abort1.rs diff --git a/tests/compile-fail/panic_abort2.rs b/tests/compile-fail/panic/panic_abort2.rs similarity index 100% rename from tests/compile-fail/panic_abort2.rs rename to tests/compile-fail/panic/panic_abort2.rs diff --git a/tests/compile-fail/panic_abort3.rs b/tests/compile-fail/panic/panic_abort3.rs similarity index 100% rename from tests/compile-fail/panic_abort3.rs rename to tests/compile-fail/panic/panic_abort3.rs diff --git a/tests/compile-fail/panic_abort4.rs b/tests/compile-fail/panic/panic_abort4.rs similarity index 100% rename from tests/compile-fail/panic_abort4.rs rename to tests/compile-fail/panic/panic_abort4.rs diff --git a/tests/run-pass/catch_panic.rs b/tests/run-pass/panic/catch_panic.rs similarity index 100% rename from tests/run-pass/catch_panic.rs rename to tests/run-pass/panic/catch_panic.rs diff --git a/tests/run-pass/catch_panic.stderr b/tests/run-pass/panic/catch_panic.stderr similarity index 100% rename from tests/run-pass/catch_panic.stderr rename to tests/run-pass/panic/catch_panic.stderr diff --git a/tests/run-pass/panic/div-by-zero-2.rs b/tests/run-pass/panic/div-by-zero-2.rs new file mode 100644 index 0000000000..6cc319bf0b --- /dev/null +++ b/tests/run-pass/panic/div-by-zero-2.rs @@ -0,0 +1,6 @@ +// ignore-windows: Unwind panicking does not currently work on Windows +#![allow(const_err)] + +fn main() { + let _n = 1 / 0; +} diff --git a/tests/run-pass/panic/div-by-zero-2.stderr b/tests/run-pass/panic/div-by-zero-2.stderr new file mode 100644 index 0000000000..77dca2aac1 --- /dev/null +++ b/tests/run-pass/panic/div-by-zero-2.stderr @@ -0,0 +1 @@ +thread 'main' panicked at 'attempt to divide by zero', $DIR/div-by-zero-2.rs:5:14 diff --git a/tests/run-pass/panic/overflowing-lsh-neg.rs b/tests/run-pass/panic/overflowing-lsh-neg.rs new file mode 100644 index 0000000000..b214243c88 --- /dev/null +++ b/tests/run-pass/panic/overflowing-lsh-neg.rs @@ -0,0 +1,7 @@ +// ignore-windows: Unwind panicking does not currently work on Windows +#![allow(exceeding_bitshifts)] +#![allow(const_err)] + +fn main() { + let _n = 2i64 << -1; +} diff --git a/tests/run-pass/panic/overflowing-lsh-neg.stderr b/tests/run-pass/panic/overflowing-lsh-neg.stderr new file mode 100644 index 0000000000..fe5a35e6b3 --- /dev/null +++ b/tests/run-pass/panic/overflowing-lsh-neg.stderr @@ -0,0 +1 @@ +thread 'main' panicked at 'attempt to shift left with overflow', $DIR/overflowing-lsh-neg.rs:6:14 diff --git a/tests/run-pass/panic/overflowing-rsh-1.rs b/tests/run-pass/panic/overflowing-rsh-1.rs new file mode 100644 index 0000000000..68ea51d167 --- /dev/null +++ b/tests/run-pass/panic/overflowing-rsh-1.rs @@ -0,0 +1,6 @@ +// ignore-windows: Unwind panicking does not currently work on Windows +#![allow(exceeding_bitshifts, const_err)] + +fn main() { + let _n = 1i64 >> 64; +} diff --git a/tests/run-pass/panic/overflowing-rsh-1.stderr b/tests/run-pass/panic/overflowing-rsh-1.stderr new file mode 100644 index 0000000000..20a45739ae --- /dev/null +++ b/tests/run-pass/panic/overflowing-rsh-1.stderr @@ -0,0 +1 @@ +thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-1.rs:5:14 diff --git a/tests/compile-fail/overflowing-rsh-2.rs b/tests/run-pass/panic/overflowing-rsh-2.rs similarity index 54% rename from tests/compile-fail/overflowing-rsh-2.rs rename to tests/run-pass/panic/overflowing-rsh-2.rs index 3f7f31f4c2..4e287f20ad 100644 --- a/tests/compile-fail/overflowing-rsh-2.rs +++ b/tests/run-pass/panic/overflowing-rsh-2.rs @@ -1,6 +1,7 @@ +// ignore-windows: Unwind panicking does not currently work on Windows #![allow(exceeding_bitshifts, const_err)] fn main() { // Make sure we catch overflows that would be hidden by first casting the RHS to u32 - let _n = 1i64 >> (u32::max_value() as i64 + 1); //~ ERROR attempt to shift right with overflow + let _n = 1i64 >> (u32::max_value() as i64 + 1); } diff --git a/tests/run-pass/panic/overflowing-rsh-2.stderr b/tests/run-pass/panic/overflowing-rsh-2.stderr new file mode 100644 index 0000000000..3381116ae6 --- /dev/null +++ b/tests/run-pass/panic/overflowing-rsh-2.stderr @@ -0,0 +1 @@ +thread 'main' panicked at 'attempt to shift right with overflow', $DIR/overflowing-rsh-2.rs:6:14 diff --git a/tests/run-pass/panic/panic1.rs b/tests/run-pass/panic/panic1.rs new file mode 100644 index 0000000000..61321c6581 --- /dev/null +++ b/tests/run-pass/panic/panic1.rs @@ -0,0 +1,4 @@ +// ignore-windows: Unwind panicking does not currently work on Windows +fn main() { + std::panic!("panicking from libstd"); +} diff --git a/tests/run-pass/panic/panic1.stderr b/tests/run-pass/panic/panic1.stderr new file mode 100644 index 0000000000..305fc1a1a6 --- /dev/null +++ b/tests/run-pass/panic/panic1.stderr @@ -0,0 +1 @@ +thread 'main' panicked at 'panicking from libstd', $DIR/panic1.rs:3:5 diff --git a/tests/run-pass/panic/panic2.rs b/tests/run-pass/panic/panic2.rs new file mode 100644 index 0000000000..d6ab864795 --- /dev/null +++ b/tests/run-pass/panic/panic2.rs @@ -0,0 +1,4 @@ +// ignore-windows: Unwind panicking does not currently work on Windows +fn main() { + std::panic!("{}-panicking from libstd", 42); +} diff --git a/tests/run-pass/panic/panic2.stderr b/tests/run-pass/panic/panic2.stderr new file mode 100644 index 0000000000..cd40559c81 --- /dev/null +++ b/tests/run-pass/panic/panic2.stderr @@ -0,0 +1 @@ +thread 'main' panicked at '42-panicking from libstd', $DIR/panic2.rs:3:5 diff --git a/tests/run-pass/panic/panic3.rs b/tests/run-pass/panic/panic3.rs new file mode 100644 index 0000000000..10a42c7e6c --- /dev/null +++ b/tests/run-pass/panic/panic3.rs @@ -0,0 +1,4 @@ +// ignore-windows: Unwind panicking does not currently work on Windows +fn main() { + core::panic!("panicking from libcore"); +} diff --git a/tests/run-pass/panic/panic3.stderr b/tests/run-pass/panic/panic3.stderr new file mode 100644 index 0000000000..e3aa902f0c --- /dev/null +++ b/tests/run-pass/panic/panic3.stderr @@ -0,0 +1 @@ +thread 'main' panicked at 'panicking from libcore', $DIR/panic3.rs:3:5 diff --git a/tests/run-pass/panic/panic4.rs b/tests/run-pass/panic/panic4.rs new file mode 100644 index 0000000000..06e2dd008f --- /dev/null +++ b/tests/run-pass/panic/panic4.rs @@ -0,0 +1,4 @@ +// ignore-windows: Unwind panicking does not currently work on Windows +fn main() { + core::panic!("{}-panicking from libcore", 42); +} diff --git a/tests/run-pass/panic/panic4.stderr b/tests/run-pass/panic/panic4.stderr new file mode 100644 index 0000000000..1a242a868c --- /dev/null +++ b/tests/run-pass/panic/panic4.stderr @@ -0,0 +1 @@ +thread 'main' panicked at '42-panicking from libcore', $DIR/panic4.rs:3:5 diff --git a/tests/compile-fail/transmute_fat2.rs b/tests/run-pass/panic/transmute_fat2.rs similarity index 76% rename from tests/compile-fail/transmute_fat2.rs rename to tests/run-pass/panic/transmute_fat2.rs index 3121a139d9..40b3bd9d10 100644 --- a/tests/compile-fail/transmute_fat2.rs +++ b/tests/run-pass/panic/transmute_fat2.rs @@ -7,5 +7,5 @@ fn main() { let bad = unsafe { std::mem::transmute::(42) }; - bad[0]; //~ ERROR index out of bounds: the len is 0 but the index is 0 + bad[0]; } diff --git a/tests/run-pass/panic/transmute_fat2.stderr b/tests/run-pass/panic/transmute_fat2.stderr new file mode 100644 index 0000000000..62f3787723 --- /dev/null +++ b/tests/run-pass/panic/transmute_fat2.stderr @@ -0,0 +1 @@ +thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:10:5 From 1b3434c67d27da6cf4c758b517fe132d5295bf02 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 29 Nov 2019 19:50:37 +0100 Subject: [PATCH 06/12] adjust for init_allocation_extra --- src/machine.rs | 21 +++++++++------------ src/stacked_borrows.rs | 14 +++++++++++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/machine.rs b/src/machine.rs index 980c6115e9..b974c956c2 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -291,27 +291,24 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> { Ok(()) } - fn tag_allocation<'b>( + fn init_allocation_extra<'b>( memory_extra: &MemoryExtra, id: AllocId, alloc: Cow<'b, Allocation>, kind: Option>, - ) -> ( - Cow<'b, Allocation>, - Self::PointerTag, - ) { + ) -> Cow<'b, Allocation> { let kind = kind.expect("we set our STATIC_KIND so this cannot be None"); let alloc = alloc.into_owned(); - let (stacks, base_tag) = if !memory_extra.validate { - (None, Tag::Untagged) - } else { - let (stacks, base_tag) = Stacks::new_allocation( + let stacks = if memory_extra.validate { + Some(Stacks::new_allocation( id, alloc.size, Rc::clone(&memory_extra.stacked_borrows), kind, - ); - (Some(stacks), base_tag) + )) + } else { + // No stacks. + None }; let mut stacked_borrows = memory_extra.stacked_borrows.borrow_mut(); let alloc: Allocation = alloc.with_tags_and_extra( @@ -328,7 +325,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> { stacked_borrows: stacks, }, ); - (Cow::Owned(alloc), base_tag) + Cow::Owned(alloc) } #[inline(always)] diff --git a/src/stacked_borrows.rs b/src/stacked_borrows.rs index 3b821c7155..dc06f12ffe 100644 --- a/src/stacked_borrows.rs +++ b/src/stacked_borrows.rs @@ -462,7 +462,7 @@ impl Stacks { size: Size, extra: MemoryExtra, kind: MemoryKind, - ) -> (Self, Tag) { + ) -> Self { let (tag, perm) = match kind { MemoryKind::Stack => // New unique borrow. This tag is not accessible by the program, @@ -472,12 +472,15 @@ impl Stacks { // and in particular, *all* raw pointers. (Tag::Tagged(extra.borrow_mut().new_ptr()), Permission::Unique), MemoryKind::Machine(MiriMemoryKind::Static) => + // Statics are inherently shared, so we do not derive any uniqueness assumptions + // from direct accesses to a static. Thus, the base permission is `SharedReadWrite`. (extra.borrow_mut().static_base_ptr(id), Permission::SharedReadWrite), _ => + // Everything else we handle entirely untagged for now. + // FIXME: experiment with more precise tracking. (Tag::Untagged, Permission::SharedReadWrite), }; - let stack = Stacks::new(size, perm, tag, extra); - (stack, tag) + Stacks::new(size, perm, tag, extra) } #[inline(always)] @@ -591,7 +594,12 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx // Compute new borrow. let new_tag = match kind { + // Give up tracking for raw pointers. + // FIXME: Experiment with more precise tracking. Blocked on `&raw` + // because `Rc::into_raw` currently creates intermediate references, + // breaking `Rc::from_raw`. RefKind::Raw { .. } => Tag::Untagged, + // All other pointesr are properly tracked. _ => Tag::Tagged(this.memory.extra.stacked_borrows.borrow_mut().new_ptr()), }; From f1cde6d80b9bef9808832b5b7ea322925c04fe5b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 30 Nov 2019 10:37:14 +0100 Subject: [PATCH 07/12] also test built-in panics via should_panic --- test-cargo-miri/test.stdout.ref | 5 +++-- test-cargo-miri/test.stdout.ref2 | 2 +- test-cargo-miri/test.stdout.ref3 | 2 +- test-cargo-miri/tests/test.rs | 11 ++++++++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/test-cargo-miri/test.stdout.ref b/test-cargo-miri/test.stdout.ref index 827e2f9323..0ab948893b 100644 --- a/test-cargo-miri/test.stdout.ref +++ b/test-cargo-miri/test.stdout.ref @@ -5,12 +5,13 @@ test test::rng ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -running 5 tests +running 6 tests test do_panic ... ok test entropy_rng ... ok +test fail_index_check ... ok test num_cpus ... ok test simple1 ... ok test simple2 ... ok -test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out diff --git a/test-cargo-miri/test.stdout.ref2 b/test-cargo-miri/test.stdout.ref2 index e070941c36..1dd4f70658 100644 --- a/test-cargo-miri/test.stdout.ref2 +++ b/test-cargo-miri/test.stdout.ref2 @@ -7,5 +7,5 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out running 1 test test simple1 ... ok -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out diff --git a/test-cargo-miri/test.stdout.ref3 b/test-cargo-miri/test.stdout.ref3 index a4a1a7812a..af94192a12 100644 --- a/test-cargo-miri/test.stdout.ref3 +++ b/test-cargo-miri/test.stdout.ref3 @@ -7,5 +7,5 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out running 1 test test num_cpus ... ok -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 4 filtered out +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out diff --git a/test-cargo-miri/tests/test.rs b/test-cargo-miri/tests/test.rs index ce85f92904..76d3eeece5 100644 --- a/test-cargo-miri/tests/test.rs +++ b/test-cargo-miri/tests/test.rs @@ -43,7 +43,7 @@ fn num_cpus() { } -// FIXME: Remove this `cfg` once we fix https://github.com/rust-lang/miri/issues/1059 +// FIXME: Remove this `cfg` once we fix https://github.com/rust-lang/miri/issues/1059. // We cfg-gate the `should_panic` attribute and the `panic!` itself, so that the test // stdout does not depend on the platform. #[test] @@ -52,3 +52,12 @@ fn do_panic() { // In large, friendly letters :) #[cfg(not(windows))] panic!("Explicit panic from test!"); } + +// FIXME: see above +#[test] +#[allow(const_err)] +#[cfg_attr(not(windows), should_panic(expected="the len is 0 but the index is 42"))] +fn fail_index_check() { + #[cfg(not(windows))] + [][42] +} From e77258322c71091afe23ecb64461243174e7fd49 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 30 Nov 2019 11:48:34 +0100 Subject: [PATCH 08/12] some error classes should be impossible --- src/eval.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/eval.rs b/src/eval.rs index 33bcfcc738..17c0d52b00 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -217,6 +217,8 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) -> } err_unsup!(NoMirFor(..)) => format!("{}. Did you set `MIRI_SYSROOT` to a Miri-enabled sysroot? You can prepare one with `cargo miri setup`.", e), + InterpError::Panic(_) | InterpError::InvalidProgram(_) => + bug!("This error should be impossible in Miri: {}", e), _ => e.to_string() }; e.print_backtrace(); From d43e394c4691f6ae9173001a27943d74ef6c5f97 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 1 Dec 2019 10:18:41 +0100 Subject: [PATCH 09/12] fix init_allocation_extra --- src/eval.rs | 6 +++--- src/machine.rs | 19 ++++++++++--------- src/shims/panic.rs | 2 +- src/stacked_borrows.rs | 10 ++++++---- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/eval.rs b/src/eval.rs index 17c0d52b00..2796dbd0b9 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -93,7 +93,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( arg.push(0); argvs.push( ecx.memory - .allocate_static_bytes(arg.as_slice(), MiriMemoryKind::Static.into()), + .allocate_static_bytes(arg.as_slice(), MiriMemoryKind::Env.into()), ); } // Make an array with all these pointers, in the Miri memory. @@ -144,7 +144,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( // Return place (in static memory so that it does not count as leak). let ret_place = ecx.allocate( ecx.layout_of(tcx.types.isize)?, - MiriMemoryKind::Static.into(), + MiriMemoryKind::Env.into(), ); // Call start function. ecx.call_function( @@ -156,7 +156,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>( // Set the last_error to 0 let errno_layout = ecx.layout_of(tcx.types.u32)?; - let errno_place = ecx.allocate(errno_layout, MiriMemoryKind::Static.into()); + let errno_place = ecx.allocate(errno_layout, MiriMemoryKind::Env.into()); ecx.write_scalar(Scalar::from_u32(0), errno_place.into())?; ecx.machine.last_error = Some(errno_place); diff --git a/src/machine.rs b/src/machine.rs index b974c956c2..edabc3bccb 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -43,9 +43,9 @@ pub enum MiriMemoryKind { C, /// Windows `HeapAlloc` memory. WinHeap, - /// Part of env var emulation. + /// Memory for env vars and args, errno and other parts of the machine-managed environment. Env, - /// Statics. + /// Rust statics. Static, } @@ -296,19 +296,20 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> { id: AllocId, alloc: Cow<'b, Allocation>, kind: Option>, - ) -> Cow<'b, Allocation> { + ) -> (Cow<'b, Allocation>, Self::PointerTag) { let kind = kind.expect("we set our STATIC_KIND so this cannot be None"); let alloc = alloc.into_owned(); - let stacks = if memory_extra.validate { - Some(Stacks::new_allocation( + let (stacks, base_tag) = if memory_extra.validate { + let (stacks, base_tag) = Stacks::new_allocation( id, alloc.size, Rc::clone(&memory_extra.stacked_borrows), kind, - )) + ); + (Some(stacks), base_tag) } else { - // No stacks. - None + // No stacks, no tag. + (None, Tag::Untagged) }; let mut stacked_borrows = memory_extra.stacked_borrows.borrow_mut(); let alloc: Allocation = alloc.with_tags_and_extra( @@ -325,7 +326,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> { stacked_borrows: stacks, }, ); - Cow::Owned(alloc) + (Cow::Owned(alloc), base_tag) } #[inline(always)] diff --git a/src/shims/panic.rs b/src/shims/panic.rs index 3e82519f86..fc3339352a 100644 --- a/src/shims/panic.rs +++ b/src/shims/panic.rs @@ -187,7 +187,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx // First arg: Message. let msg = msg.description(); - let msg = this.allocate_str(msg, MiriMemoryKind::Static.into()); + let msg = this.allocate_str(msg, MiriMemoryKind::Env.into()); // Second arg: Caller location. let location = this.alloc_caller_location_for_span(span); diff --git a/src/stacked_borrows.rs b/src/stacked_borrows.rs index dc06f12ffe..23a32fc2ac 100644 --- a/src/stacked_borrows.rs +++ b/src/stacked_borrows.rs @@ -462,7 +462,7 @@ impl Stacks { size: Size, extra: MemoryExtra, kind: MemoryKind, - ) -> Self { + ) -> (Self, Tag) { let (tag, perm) = match kind { MemoryKind::Stack => // New unique borrow. This tag is not accessible by the program, @@ -472,15 +472,17 @@ impl Stacks { // and in particular, *all* raw pointers. (Tag::Tagged(extra.borrow_mut().new_ptr()), Permission::Unique), MemoryKind::Machine(MiriMemoryKind::Static) => - // Statics are inherently shared, so we do not derive any uniqueness assumptions - // from direct accesses to a static. Thus, the base permission is `SharedReadWrite`. + // Static memory can be referenced by "global" pointers from `tcx`. + // Thus we call `static_base_ptr` such that the global pointers get the same tag + // as what we use here. + // The base pointer is not unique, so the base permission is `SharedReadWrite`. (extra.borrow_mut().static_base_ptr(id), Permission::SharedReadWrite), _ => // Everything else we handle entirely untagged for now. // FIXME: experiment with more precise tracking. (Tag::Untagged, Permission::SharedReadWrite), }; - Stacks::new(size, perm, tag, extra) + (Stacks::new(size, perm, tag, extra), tag) } #[inline(always)] From 8e3c3eccc46a839e81ad2806d9507ab555260556 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 1 Dec 2019 10:19:01 +0100 Subject: [PATCH 10/12] panic errors are actually still possible --- src/eval.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eval.rs b/src/eval.rs index 2796dbd0b9..197cf87ba5 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -217,7 +217,7 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) -> } err_unsup!(NoMirFor(..)) => format!("{}. Did you set `MIRI_SYSROOT` to a Miri-enabled sysroot? You can prepare one with `cargo miri setup`.", e), - InterpError::Panic(_) | InterpError::InvalidProgram(_) => + InterpError::InvalidProgram(_) => bug!("This error should be impossible in Miri: {}", e), _ => e.to_string() }; From 2ef5ac17cc1a6a3d2263d3a3382eba37e5252325 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 2 Dec 2019 16:04:51 +0100 Subject: [PATCH 11/12] rustup --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index b2b29eb527..ebf6e5a2ac 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -4af3ee8ee2a2bc1286b021db7600ba990359cf3f +2da942f32802c8233a09744024dfbc34431adf65 From ce7b44b048820edc6b29873a708ec12c760db64b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 2 Dec 2019 16:48:18 +0100 Subject: [PATCH 12/12] ignore another panicking test on Windows --- tests/run-pass/panic/transmute_fat2.rs | 1 + tests/run-pass/panic/transmute_fat2.stderr | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/run-pass/panic/transmute_fat2.rs b/tests/run-pass/panic/transmute_fat2.rs index 40b3bd9d10..8cbe9a099b 100644 --- a/tests/run-pass/panic/transmute_fat2.rs +++ b/tests/run-pass/panic/transmute_fat2.rs @@ -1,3 +1,4 @@ +// ignore-windows: Unwind panicking does not currently work on Windows fn main() { #[cfg(target_pointer_width="64")] let bad = unsafe { diff --git a/tests/run-pass/panic/transmute_fat2.stderr b/tests/run-pass/panic/transmute_fat2.stderr index 62f3787723..08849a5b51 100644 --- a/tests/run-pass/panic/transmute_fat2.stderr +++ b/tests/run-pass/panic/transmute_fat2.stderr @@ -1 +1 @@ -thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:10:5 +thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', $DIR/transmute_fat2.rs:11:5