@@ -111,7 +111,7 @@ pub struct GlobalState {
111
111
pub type MemoryExtra = RefCell < GlobalState > ;
112
112
113
113
/// Indicates which kind of access is being performed.
114
- #[ derive( Copy , Clone , Hash , PartialEq , Eq ) ]
114
+ #[ derive( Copy , Clone , Hash , PartialEq , Eq , Debug ) ]
115
115
pub enum AccessKind {
116
116
Read ,
117
117
Write ,
@@ -296,19 +296,26 @@ impl<'tcx> Stack {
296
296
}
297
297
298
298
/// Check if the given item is protected.
299
+ ///
300
+ /// The `provoking_access` argument is only used to produce diagnostics.
301
+ /// It is `Some` when we are granting the contained access for said tag, and it is
302
+ /// `None` during a deallocation.
299
303
fn check_protector (
300
304
item : & Item ,
301
- tag : Option < SbTag > ,
305
+ provoking_access : Option < ( SbTag , AccessKind ) > ,
302
306
global : & GlobalState ,
303
307
) -> InterpResult < ' tcx > {
304
308
if let SbTag :: Tagged ( id) = item. tag {
305
309
if Some ( id) == global. tracked_pointer_tag {
306
- register_diagnostic ( NonHaltingDiagnostic :: PoppedPointerTag ( item. clone ( ) ) ) ;
310
+ register_diagnostic ( NonHaltingDiagnostic :: PoppedPointerTag (
311
+ item. clone ( ) ,
312
+ provoking_access,
313
+ ) ) ;
307
314
}
308
315
}
309
316
if let Some ( call) = item. protector {
310
317
if global. is_active ( call) {
311
- if let Some ( tag) = tag {
318
+ if let Some ( ( tag, _ ) ) = provoking_access {
312
319
Err ( err_sb_ub ( format ! (
313
320
"not granting access to tag {:?} because incompatible item is protected: {:?}" ,
314
321
tag, item
@@ -348,7 +355,7 @@ impl<'tcx> Stack {
348
355
let first_incompatible_idx = self . find_first_write_incompatible ( granting_idx) ;
349
356
for item in self . borrows . drain ( first_incompatible_idx..) . rev ( ) {
350
357
trace ! ( "access: popping item {:?}" , item) ;
351
- Stack :: check_protector ( & item, Some ( tag) , global) ?;
358
+ Stack :: check_protector ( & item, Some ( ( tag, access ) ) , global) ?;
352
359
}
353
360
} else {
354
361
// On a read, *disable* all `Unique` above the granting item. This ensures U2 for read accesses.
@@ -363,7 +370,7 @@ impl<'tcx> Stack {
363
370
let item = & mut self . borrows [ idx] ;
364
371
if item. perm == Permission :: Unique {
365
372
trace ! ( "access: disabling item {:?}" , item) ;
366
- Stack :: check_protector ( item, Some ( tag) , global) ?;
373
+ Stack :: check_protector ( item, Some ( ( tag, access ) ) , global) ?;
367
374
item. perm = Permission :: Disabled ;
368
375
}
369
376
}
0 commit comments