@@ -185,7 +185,10 @@ fn mutex_create<'tcx>(
185185fn mutex_get_data < ' tcx , ' a > (
186186 ecx : & ' a mut MiriInterpCx < ' tcx > ,
187187 mutex_ptr : & OpTy < ' tcx > ,
188- ) -> InterpResult < ' tcx , PthreadMutex > {
188+ ) -> InterpResult < ' tcx , & ' a PthreadMutex >
189+ where
190+ ' tcx : ' a ,
191+ {
189192 let mutex = ecx. deref_pointer ( mutex_ptr) ?;
190193 ecx. lazy_sync_get_data (
191194 & mutex,
@@ -259,10 +262,13 @@ fn rwlock_init_offset<'tcx>(ecx: &MiriInterpCx<'tcx>) -> InterpResult<'tcx, Size
259262 interp_ok ( offset)
260263}
261264
262- fn rwlock_get_data < ' tcx > (
263- ecx : & mut MiriInterpCx < ' tcx > ,
265+ fn rwlock_get_data < ' tcx , ' a > (
266+ ecx : & ' a mut MiriInterpCx < ' tcx > ,
264267 rwlock_ptr : & OpTy < ' tcx > ,
265- ) -> InterpResult < ' tcx , PthreadRwLock > {
268+ ) -> InterpResult < ' tcx , & ' a PthreadRwLock >
269+ where
270+ ' tcx : ' a ,
271+ {
266272 let rwlock = ecx. deref_pointer ( rwlock_ptr) ?;
267273 ecx. lazy_sync_get_data (
268274 & rwlock,
@@ -389,10 +395,13 @@ fn cond_create<'tcx>(
389395 interp_ok ( data)
390396}
391397
392- fn cond_get_data < ' tcx > (
393- ecx : & mut MiriInterpCx < ' tcx > ,
398+ fn cond_get_data < ' tcx , ' a > (
399+ ecx : & ' a mut MiriInterpCx < ' tcx > ,
394400 cond_ptr : & OpTy < ' tcx > ,
395- ) -> InterpResult < ' tcx , PthreadCondvar > {
401+ ) -> InterpResult < ' tcx , & ' a PthreadCondvar >
402+ where
403+ ' tcx : ' a ,
404+ {
396405 let cond = ecx. deref_pointer ( cond_ptr) ?;
397406 ecx. lazy_sync_get_data (
398407 & cond,
@@ -498,7 +507,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
498507 ) -> InterpResult < ' tcx > {
499508 let this = self . eval_context_mut ( ) ;
500509
501- let mutex = mutex_get_data ( this, mutex_op) ?;
510+ let mutex = mutex_get_data ( this, mutex_op) ?. clone ( ) ;
502511
503512 let ret = if this. mutex_is_locked ( & mutex. mutex_ref ) {
504513 let owner_thread = this. mutex_get_owner ( & mutex. mutex_ref ) ;
@@ -535,7 +544,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
535544 fn pthread_mutex_trylock ( & mut self , mutex_op : & OpTy < ' tcx > ) -> InterpResult < ' tcx , Scalar > {
536545 let this = self . eval_context_mut ( ) ;
537546
538- let mutex = mutex_get_data ( this, mutex_op) ?;
547+ let mutex = mutex_get_data ( this, mutex_op) ?. clone ( ) ;
539548
540549 interp_ok ( Scalar :: from_i32 ( if this. mutex_is_locked ( & mutex. mutex_ref ) {
541550 let owner_thread = this. mutex_get_owner ( & mutex. mutex_ref ) ;
@@ -561,7 +570,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
561570 fn pthread_mutex_unlock ( & mut self , mutex_op : & OpTy < ' tcx > ) -> InterpResult < ' tcx , Scalar > {
562571 let this = self . eval_context_mut ( ) ;
563572
564- let mutex = mutex_get_data ( this, mutex_op) ?;
573+ let mutex = mutex_get_data ( this, mutex_op) ?. clone ( ) ;
565574
566575 if let Some ( _old_locked_count) = this. mutex_unlock ( & mutex. mutex_ref ) ? {
567576 // The mutex was locked by the current thread.
@@ -589,8 +598,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
589598 let this = self . eval_context_mut ( ) ;
590599
591600 // 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 ( ) ;
594603
595604 if this. mutex_is_locked ( & mutex. mutex_ref ) {
596605 throw_ub_format ! ( "destroyed a locked mutex" ) ;
@@ -697,7 +706,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
697706 let this = self . eval_context_mut ( ) ;
698707
699708 // 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.
701710 let id = rwlock_get_data ( this, rwlock_op) ?. id ;
702711
703712 if this. rwlock_is_locked ( id) {
@@ -822,8 +831,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
822831 ) -> InterpResult < ' tcx > {
823832 let this = self . eval_context_mut ( ) ;
824833
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 ( ) ;
827836
828837 this. condvar_wait (
829838 data. id ,
@@ -846,8 +855,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
846855 ) -> InterpResult < ' tcx > {
847856 let this = self . eval_context_mut ( ) ;
848857
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 ( ) ;
851860
852861 // Extract the timeout.
853862 let duration = match this
@@ -884,7 +893,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
884893 let this = self . eval_context_mut ( ) ;
885894
886895 // 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.
888897 let id = cond_get_data ( this, cond_op) ?. id ;
889898 if this. condvar_is_awaited ( id) {
890899 throw_ub_format ! ( "destroying an awaited conditional variable" ) ;
0 commit comments