@@ -66,13 +66,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
66
66
if op == wait { this. machine . layouts . isize } else { this. machine . layouts . u32 } ;
67
67
let obj = this. ptr_to_mplace ( obj, obj_layout) ;
68
68
69
- // Read the Linux futex implementation in Miri to understand why this fence is needed.
69
+ // Read the Linux futex wait implementation in Miri to understand why this fence is needed.
70
70
this. atomic_fence ( AtomicFenceOrd :: SeqCst ) ?;
71
71
let obj_val = this
72
72
. read_scalar_atomic ( & obj, AtomicReadOrd :: Acquire ) ?
73
73
. to_bits ( obj_layout. size ) ?; // isize and u32 can have different sizes
74
74
75
75
if obj_val == u128:: from ( val) {
76
+ // This cannot fail since we already did an atomic acquire read on that pointer.
77
+ // Acquire reads are only allowed on mutable memory.
76
78
let futex_ref = this
77
79
. get_sync_or_init ( obj. ptr ( ) , |_| FreeBsdFutex { futex : Default :: default ( ) } )
78
80
. unwrap ( )
@@ -122,7 +124,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
122
124
} ;
123
125
124
126
// From the FreeBSD source code:
125
- // In the function `umtx_copyin_umtx_time` in kern_umtx.c, _clock_id is set to CLOCK_REALTIME when using `timespec`
127
+ // In the function `umtx_copyin_umtx_time` in kern_umtx.c,
128
+ // _clock_id is set to CLOCK_REALTIME when using a `timespec` timeout.
126
129
Some ( ( TimeoutClock :: RealTime , TimeoutAnchor :: Relative , duration) )
127
130
} else {
128
131
return this. set_last_error_and_return ( LibcError ( "EINVAL" ) , dest) ;
@@ -177,7 +180,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
177
180
// Saturating cast for when usize is smaller than u64.
178
181
let count = usize:: try_from ( val) . unwrap_or ( usize:: MAX ) ;
179
182
180
- // Read the Linux futex implementation in Miri to understand why this fence is needed.
183
+ // Read the Linux futex wake implementation in Miri to understand why this fence is needed.
181
184
this. atomic_fence ( AtomicFenceOrd :: SeqCst ) ?;
182
185
183
186
// `_umtx_op` doesn't return the amount of woken threads.
0 commit comments