@@ -185,7 +185,10 @@ fn mutex_create<'tcx>(
185
185
fn mutex_get_data < ' tcx , ' a > (
186
186
ecx : & ' a mut MiriInterpCx < ' tcx > ,
187
187
mutex_ptr : & OpTy < ' tcx > ,
188
- ) -> InterpResult < ' tcx , PthreadMutex > {
188
+ ) -> InterpResult < ' tcx , & ' a PthreadMutex >
189
+ where
190
+ ' tcx : ' a ,
191
+ {
189
192
let mutex = ecx. deref_pointer ( mutex_ptr) ?;
190
193
ecx. lazy_sync_get_data (
191
194
& mutex,
@@ -259,10 +262,13 @@ fn rwlock_init_offset<'tcx>(ecx: &MiriInterpCx<'tcx>) -> InterpResult<'tcx, Size
259
262
interp_ok ( offset)
260
263
}
261
264
262
- fn rwlock_get_data < ' tcx > (
263
- ecx : & mut MiriInterpCx < ' tcx > ,
265
+ fn rwlock_get_data < ' tcx , ' a > (
266
+ ecx : & ' a mut MiriInterpCx < ' tcx > ,
264
267
rwlock_ptr : & OpTy < ' tcx > ,
265
- ) -> InterpResult < ' tcx , PthreadRwLock > {
268
+ ) -> InterpResult < ' tcx , & ' a PthreadRwLock >
269
+ where
270
+ ' tcx : ' a ,
271
+ {
266
272
let rwlock = ecx. deref_pointer ( rwlock_ptr) ?;
267
273
ecx. lazy_sync_get_data (
268
274
& rwlock,
@@ -389,10 +395,13 @@ fn cond_create<'tcx>(
389
395
interp_ok ( data)
390
396
}
391
397
392
- fn cond_get_data < ' tcx > (
393
- ecx : & mut MiriInterpCx < ' tcx > ,
398
+ fn cond_get_data < ' tcx , ' a > (
399
+ ecx : & ' a mut MiriInterpCx < ' tcx > ,
394
400
cond_ptr : & OpTy < ' tcx > ,
395
- ) -> InterpResult < ' tcx , PthreadCondvar > {
401
+ ) -> InterpResult < ' tcx , & ' a PthreadCondvar >
402
+ where
403
+ ' tcx : ' a ,
404
+ {
396
405
let cond = ecx. deref_pointer ( cond_ptr) ?;
397
406
ecx. lazy_sync_get_data (
398
407
& cond,
@@ -498,7 +507,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
498
507
) -> InterpResult < ' tcx > {
499
508
let this = self . eval_context_mut ( ) ;
500
509
501
- let mutex = mutex_get_data ( this, mutex_op) ?;
510
+ let mutex = mutex_get_data ( this, mutex_op) ?. clone ( ) ;
502
511
503
512
let ret = if this. mutex_is_locked ( & mutex. mutex_ref ) {
504
513
let owner_thread = this. mutex_get_owner ( & mutex. mutex_ref ) ;
@@ -535,7 +544,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
535
544
fn pthread_mutex_trylock ( & mut self , mutex_op : & OpTy < ' tcx > ) -> InterpResult < ' tcx , Scalar > {
536
545
let this = self . eval_context_mut ( ) ;
537
546
538
- let mutex = mutex_get_data ( this, mutex_op) ?;
547
+ let mutex = mutex_get_data ( this, mutex_op) ?. clone ( ) ;
539
548
540
549
interp_ok ( Scalar :: from_i32 ( if this. mutex_is_locked ( & mutex. mutex_ref ) {
541
550
let owner_thread = this. mutex_get_owner ( & mutex. mutex_ref ) ;
@@ -561,7 +570,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
561
570
fn pthread_mutex_unlock ( & mut self , mutex_op : & OpTy < ' tcx > ) -> InterpResult < ' tcx , Scalar > {
562
571
let this = self . eval_context_mut ( ) ;
563
572
564
- let mutex = mutex_get_data ( this, mutex_op) ?;
573
+ let mutex = mutex_get_data ( this, mutex_op) ?. clone ( ) ;
565
574
566
575
if let Some ( _old_locked_count) = this. mutex_unlock ( & mutex. mutex_ref ) ? {
567
576
// The mutex was locked by the current thread.
@@ -589,8 +598,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
589
598
let this = self . eval_context_mut ( ) ;
590
599
591
600
// Reading the field also has the side-effect that we detect double-`destroy`
592
- // since we make the field unint below.
593
- let mutex = mutex_get_data ( this, mutex_op) ?;
601
+ // since we make the field uninit below.
602
+ let mutex = mutex_get_data ( this, mutex_op) ?. clone ( ) ;
594
603
595
604
if this. mutex_is_locked ( & mutex. mutex_ref ) {
596
605
throw_ub_format ! ( "destroyed a locked mutex" ) ;
@@ -697,7 +706,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
697
706
let this = self . eval_context_mut ( ) ;
698
707
699
708
// Reading the field also has the side-effect that we detect double-`destroy`
700
- // since we make the field unint below.
709
+ // since we make the field uninit below.
701
710
let id = rwlock_get_data ( this, rwlock_op) ?. id ;
702
711
703
712
if this. rwlock_is_locked ( id) {
@@ -822,8 +831,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
822
831
) -> InterpResult < ' tcx > {
823
832
let this = self . eval_context_mut ( ) ;
824
833
825
- let data = cond_get_data ( this, cond_op) ?;
826
- let mutex_ref = mutex_get_data ( this, mutex_op) ?. mutex_ref ;
834
+ let data = * cond_get_data ( this, cond_op) ?;
835
+ let mutex_ref = mutex_get_data ( this, mutex_op) ?. mutex_ref . clone ( ) ;
827
836
828
837
this. condvar_wait (
829
838
data. id ,
@@ -846,8 +855,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
846
855
) -> InterpResult < ' tcx > {
847
856
let this = self . eval_context_mut ( ) ;
848
857
849
- let data = cond_get_data ( this, cond_op) ?;
850
- let mutex_ref = mutex_get_data ( this, mutex_op) ?. mutex_ref ;
858
+ let data = * cond_get_data ( this, cond_op) ?;
859
+ let mutex_ref = mutex_get_data ( this, mutex_op) ?. mutex_ref . clone ( ) ;
851
860
852
861
// Extract the timeout.
853
862
let duration = match this
@@ -884,7 +893,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
884
893
let this = self . eval_context_mut ( ) ;
885
894
886
895
// Reading the field also has the side-effect that we detect double-`destroy`
887
- // since we make the field unint below.
896
+ // since we make the field uninit below.
888
897
let id = cond_get_data ( this, cond_op) ?. id ;
889
898
if this. condvar_is_awaited ( id) {
890
899
throw_ub_format ! ( "destroying an awaited conditional variable" ) ;
0 commit comments