Skip to content

Commit c60efa0

Browse files
committed
allocate backtrace strings mutably
1 parent 9e0e938 commit c60efa0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/shims/backtrace.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
119119
// `lo.col` is 0-based - add 1 to make it 1-based for the caller.
120120
let colno: u32 = lo.col.0 as u32 + 1;
121121

122-
let name_alloc = this.allocate_str(&name, MiriMemoryKind::Rust.into());
123-
let filename_alloc = this.allocate_str(&filename, MiriMemoryKind::Rust.into());
122+
// These are "mutable" allocations as we consider them to be owned by the callee.
123+
let name_alloc = this.allocate_str(&name, MiriMemoryKind::Rust.into(), Mutability::Mut);
124+
let filename_alloc =
125+
this.allocate_str(&filename, MiriMemoryKind::Rust.into(), Mutability::Mut);
124126
let lineno_alloc = Scalar::from_u32(lineno);
125127
let colno_alloc = Scalar::from_u32(colno);
126128

src/shims/panic.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
1414
use log::trace;
1515

16+
use rustc_ast::Mutability;
1617
use rustc_middle::{mir, ty};
1718
use rustc_target::spec::abi::Abi;
1819
use rustc_target::spec::PanicStrategy;
@@ -169,7 +170,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
169170
let this = self.eval_context_mut();
170171

171172
// First arg: message.
172-
let msg = this.allocate_str(msg, MiriMemoryKind::Machine.into());
173+
let msg = this.allocate_str(msg, MiriMemoryKind::Machine.into(), Mutability::Not);
173174

174175
// Call the lang item.
175176
let panic = this.tcx.lang_items().panic_fn().unwrap();

0 commit comments

Comments
 (0)