Skip to content

Commit 486a769

Browse files
committed
Handle diagnotics emitted in runtime initialization
1 parent b96610b commit 486a769

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/eval.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
168168
param_env,
169169
Evaluator::new(config, layout_cx),
170170
);
171+
172+
// Capture the current interpreter stack state (which should be empty) so that we can emit
173+
// allocation-tracking and tag-tracking diagnostics for allocations which are part of the
174+
// runtime.
175+
let info = ecx.preprocess_diagnostics();
176+
171177
// Some parts of initialization require a full `InterpCx`.
172178
Evaluator::late_init(&mut ecx, config)?;
173179

@@ -287,6 +293,10 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
287293
}
288294
}
289295

296+
// Emit any diagnostics related to the setup process for the runtime, so that when the
297+
// interpreter loop starts there are no unprocessed diagnostics.
298+
ecx.process_diagnostics(info);
299+
290300
Ok((ecx, ret_place))
291301
}
292302

tests/run-pass/track-alloc-1.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Ensure that tracking early allocations doesn't ICE Miri.
2+
// Early allocations are probably part of the runtime and therefore uninteresting, but they
3+
// shouldn't cause a crash.
4+
// compile-flags: -Zmiri-track-alloc-id=1
5+
fn main() {}

tests/run-pass/track-alloc-1.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
note: tracking was triggered
2+
|
3+
= note: created allocation with id 1
4+
= note: (no span available)
5+

0 commit comments

Comments
 (0)