@@ -777,20 +777,31 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
777
777
return Ok ( ( ) )
778
778
} ;
779
779
780
- let extra = this. get_alloc_extra ( alloc_id) ?;
781
- let mut stacked_borrows = extra
782
- . stacked_borrows
783
- . as_ref ( )
784
- . expect ( "we should have Stacked Borrows data" )
785
- . borrow_mut ( ) ;
786
- stacked_borrows. history . log_creation (
787
- Some ( orig_tag) ,
788
- new_tag,
789
- alloc_range ( base_offset, size) ,
790
- current_span,
791
- ) ;
792
- if protect {
793
- stacked_borrows. history . log_protector ( orig_tag, new_tag, current_span) ;
780
+ let ( _size, _align, kind) = this. get_alloc_info ( alloc_id) ;
781
+ match kind {
782
+ AllocKind :: LiveData => {
783
+ // This should have alloc_extra data, but `get_alloc_extra` can still fail
784
+ // if converting this alloc_id from a global to a local one
785
+ // uncovers a non-supported `extern static`.
786
+ let extra = this. get_alloc_extra ( alloc_id) ?;
787
+ let mut stacked_borrows = extra
788
+ . stacked_borrows
789
+ . as_ref ( )
790
+ . expect ( "we should have Stacked Borrows data" )
791
+ . borrow_mut ( ) ;
792
+ stacked_borrows. history . log_creation (
793
+ Some ( orig_tag) ,
794
+ new_tag,
795
+ alloc_range ( base_offset, size) ,
796
+ current_span,
797
+ ) ;
798
+ if protect {
799
+ stacked_borrows. history . log_protector ( orig_tag, new_tag, current_span) ;
800
+ }
801
+ }
802
+ AllocKind :: Function | AllocKind :: Dead => {
803
+ // No stacked borrows on these allocations.
804
+ }
794
805
}
795
806
Ok ( ( ) )
796
807
} ;
@@ -1116,7 +1127,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
1116
1127
}
1117
1128
1118
1129
/// Mark the given tag as exposed. It was found on a pointer with the given AllocId.
1119
- fn expose_tag ( & mut self , alloc_id : AllocId , tag : SbTag ) {
1130
+ fn expose_tag ( & mut self , alloc_id : AllocId , tag : SbTag ) -> InterpResult < ' tcx > {
1120
1131
let this = self . eval_context_mut ( ) ;
1121
1132
1122
1133
// Function pointers and dead objects don't have an alloc_extra so we ignore them.
@@ -1125,14 +1136,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
1125
1136
let ( _size, _align, kind) = this. get_alloc_info ( alloc_id) ;
1126
1137
match kind {
1127
1138
AllocKind :: LiveData => {
1128
- // This should have alloc_extra data.
1129
- let alloc_extra = this. get_alloc_extra ( alloc_id) . unwrap ( ) ;
1139
+ // This should have alloc_extra data, but `get_alloc_extra` can still fail
1140
+ // if converting this alloc_id from a global to a local one
1141
+ // uncovers a non-supported `extern static`.
1142
+ let alloc_extra = this. get_alloc_extra ( alloc_id) ?;
1130
1143
trace ! ( "Stacked Borrows tag {tag:?} exposed in {alloc_id:?}" ) ;
1131
1144
alloc_extra. stacked_borrows . as_ref ( ) . unwrap ( ) . borrow_mut ( ) . exposed_tags . insert ( tag) ;
1132
1145
}
1133
1146
AllocKind :: Function | AllocKind :: Dead => {
1134
1147
// No stacked borrows on these allocations.
1135
1148
}
1136
1149
}
1150
+ Ok ( ( ) )
1137
1151
}
1138
1152
}
0 commit comments