Skip to content

Commit 1dc7173

Browse files
committed
add comments explaining the parameter mismatch check in the Apple futex code
1 parent c293de0 commit 1dc7173

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/shims/unix/macos/sync.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
154154
.unwrap();
155155

156156
// Detect mismatches between the flags and sizes used on this address
157-
// by comparing with the parameters stored with the first waiter.
157+
// by comparing it with the parameters used by the other waiters in
158+
// the current list. If the list is currently empty, update those
159+
// parameters.
158160
if futex.futex.waiters() == 0 {
159161
futex.size.set(size);
160162
futex.shared.set(is_shared);
@@ -246,7 +248,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
246248
if futex.futex.waiters() == 0 {
247249
this.set_last_error_and_return(LibcError("ENOENT"), dest)?;
248250
return interp_ok(());
249-
// Detect mismatches between the flags and sizes used on this address.
251+
// If there are waiters in the queue, they have all used the parameters
252+
// stored in `futex` (we check this in `os_sync_wait_on_address` above).
253+
// Detect mismatches between "our" parameters and the parameters used by
254+
// the waiters and return an error in that case.
250255
} else if futex.size.get() != size || futex.shared.get() != is_shared {
251256
this.set_last_error_and_return(LibcError("EINVAL"), dest)?;
252257
return interp_ok(());

0 commit comments

Comments
 (0)