@@ -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