Skip to content

Commit 5bef572

Browse files
committed
do not rely on tracing's scope exit logging, it is wrong
1 parent f94eb1b commit 5bef572

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/bin/miri.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,6 @@ fn rustc_logger_config() -> rustc_log::LoggerConfig {
208208
cfg.filter = Ok(var);
209209
}
210210
}
211-
// Enable verbose entry/exit logging by default if MIRI_LOG is set.
212-
if matches!(cfg.verbose_entry_exit, Err(VarError::NotPresent)) {
213-
cfg.verbose_entry_exit = Ok(format!("1"));
214-
}
215211
}
216212

217213
cfg

src/machine.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,13 +1454,17 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
14541454
if ecx.machine.borrow_tracker.is_some() {
14551455
ecx.on_stack_pop(frame)?;
14561456
}
1457+
// tracing-tree can autoamtically annotate scope changes, but it gets very confused by our
1458+
// concurrency and what it prints is just plain wrong. So we print our own information
1459+
// instead. (Cc https://github.com/rust-lang/miri/issues/2266)
1460+
info!("Leaving {}", ecx.frame().instance);
14571461
Ok(())
14581462
}
14591463

14601464
#[inline(always)]
14611465
fn after_stack_pop(
14621466
ecx: &mut InterpCx<'mir, 'tcx, Self>,
1463-
mut frame: Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>,
1467+
frame: Frame<'mir, 'tcx, Provenance, FrameExtra<'tcx>>,
14641468
unwinding: bool,
14651469
) -> InterpResult<'tcx, StackPopJump> {
14661470
if frame.extra.is_user_relevant {
@@ -1470,10 +1474,20 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
14701474
// user-relevant frame and restore that here.)
14711475
ecx.active_thread_mut().recompute_top_user_relevant_frame();
14721476
}
1473-
let timing = frame.extra.timing.take();
1474-
let res = ecx.handle_stack_pop_unwind(frame.extra, unwinding);
1475-
if let Some(profiler) = ecx.machine.profiler.as_ref() {
1476-
profiler.finish_recording_interval_event(timing.unwrap());
1477+
let res = {
1478+
// Move `frame`` into a sub-scope so we control when it will be dropped.
1479+
let mut frame = frame;
1480+
let timing = frame.extra.timing.take();
1481+
let res = ecx.handle_stack_pop_unwind(frame.extra, unwinding);
1482+
if let Some(profiler) = ecx.machine.profiler.as_ref() {
1483+
profiler.finish_recording_interval_event(timing.unwrap());
1484+
}
1485+
res
1486+
};
1487+
// Needs to be done after dropping frame to show up on the right nesting level.
1488+
// (Cc https://github.com/rust-lang/miri/issues/2266)
1489+
if !ecx.active_thread_stack().is_empty() {
1490+
info!("Continuing in {}", ecx.frame().instance);
14771491
}
14781492
res
14791493
}

0 commit comments

Comments
 (0)