Skip to content

Commit e3227cf

Browse files
committed
Auto merge of #2141 - saethlin:early-diagnostics-ice, r=RalfJung
Adjust diagnostics assertion so we don't ICE in setup Fixes #2076 just by handling diagnostics produced during setup. The tracking notes don't have any spans but it's better than an ICE. It looks like we leak allocations 1..20, and allocations 13..19 don't have any creation notes, and 14 only has a `FreedAlloc` alloc tracking diagnostic.
2 parents d58abab + 73534a6 commit e3227cf

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+
// early runtime setup.
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)