Skip to content

Commit

Permalink
Auto merge of #2141 - saethlin:early-diagnostics-ice, r=RalfJung
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed May 22, 2022
2 parents d58abab + 73534a6 commit e3227cf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
param_env,
Evaluator::new(config, layout_cx),
);

// Capture the current interpreter stack state (which should be empty) so that we can emit
// allocation-tracking and tag-tracking diagnostics for allocations which are part of the
// early runtime setup.
let info = ecx.preprocess_diagnostics();

// Some parts of initialization require a full `InterpCx`.
Evaluator::late_init(&mut ecx, config)?;

Expand Down Expand Up @@ -287,6 +293,10 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
}
}

// Emit any diagnostics related to the setup process for the runtime, so that when the
// interpreter loop starts there are no unprocessed diagnostics.
ecx.process_diagnostics(info);

Ok((ecx, ret_place))
}

Expand Down
5 changes: 5 additions & 0 deletions tests/run-pass/track-alloc-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Ensure that tracking early allocations doesn't ICE Miri.
// Early allocations are probably part of the runtime and therefore uninteresting, but they
// shouldn't cause a crash.
// compile-flags: -Zmiri-track-alloc-id=1
fn main() {}
5 changes: 5 additions & 0 deletions tests/run-pass/track-alloc-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
note: tracking was triggered
|
= note: created allocation with id 1
= note: (no span available)

0 comments on commit e3227cf

Please sign in to comment.