use std::cell::RefCell;
use std::fmt;
+use std::num::NonZeroU64;
use log::trace;
/// Details of premature program termination.
pub enum TerminationInfo {
Exit(i64),
- Abort(Option<String>),
+ Abort(String),
UnsupportedInIsolation(String),
ExperimentalUb { msg: String, url: String },
Deadlock,
match self {
Exit(code) =>
write!(f, "the evaluated program completed with exit code {}", code),
- Abort(None) =>
- write!(f, "the evaluated program aborted execution"),
- Abort(Some(msg)) =>
- write!(f, "the evaluated program aborted execution: {}", msg),
+ Abort(msg) =>
+ write!(f, "{}", msg),
UnsupportedInIsolation(msg) =>
write!(f, "{}", msg),
ExperimentalUb { msg, .. } =>
/// Miri specific diagnostics
pub enum NonHaltingDiagnostic {
+ CreatedPointerTag(NonZeroU64),
PoppedPointerTag(Item),
CreatedCallId(CallId),
CreatedAlloc(AllocId),
) -> Option<i64> {
use InterpError::*;
- let (title, helps) = match &e.kind {
+ let (title, helps) = match &e.kind() {
MachineStop(info) => {
let info = info.downcast_ref::<TerminationInfo>().expect("invalid MachineStop payload");
use TerminationInfo::*;
(title, helps)
}
_ => {
- let title = match e.kind {
+ let title = match e.kind() {
Unsupported(_) =>
"unsupported operation",
UndefinedBehavior(_) =>
_ =>
bug!("This error should be impossible in Miri: {}", e),
};
- let helps = match e.kind {
+ let helps = match e.kind() {
Unsupported(UnsupportedOpInfo::NoMirFor(..)) =>
vec![format!("make sure to use a Miri sysroot, which you can prepare with `cargo miri setup`")],
Unsupported(UnsupportedOpInfo::ReadBytesAsPointer | UnsupportedOpInfo::ThreadLocalStatic(_) | UnsupportedOpInfo::ReadExternStatic(_)) =>
- panic!("Error should never be raised by Miri: {:?}", e.kind),
+ panic!("Error should never be raised by Miri: {:?}", e.kind()),
Unsupported(_) =>
vec![format!("this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support")],
- UndefinedBehavior(UndefinedBehaviorInfo::AlignmentCheckFailed { .. }) =>
+ UndefinedBehavior(UndefinedBehaviorInfo::AlignmentCheckFailed { .. })
+ if ecx.memory.extra.check_alignment == AlignmentCheck::Symbolic
+ =>
vec![
format!("this usually indicates that your program performed an invalid operation and caused Undefined Behavior"),
- format!("but alignment errors can also be false positives, see https://github.com/rust-lang/miri/issues/1074"),
- format!("you can disable the alignment check with `-Zmiri-disable-alignment-check`, but that could hide true bugs")
+ format!("but due to `-Zmiri-symbolic-alignment-check`, alignment errors can also be false positives"),
],
UndefinedBehavior(_) =>
vec![
}
// Extra output to help debug specific issues.
- match e.kind {
+ match e.kind() {
UndefinedBehavior(UndefinedBehaviorInfo::InvalidUninitBytes(Some(access))) => {
eprintln!(
"Uninitialized read occurred at offsets 0x{:x}..0x{:x} into this allocation:",
for e in diagnostics.drain(..) {
use NonHaltingDiagnostic::*;
let msg = match e {
+ CreatedPointerTag(tag) =>
+ format!("created tag {:?}", tag),
PoppedPointerTag(item) =>
format!("popped tracked tag for item {:?}", item),
CreatedCallId(id) =>