Skip to content

Commit fd830e7

Browse files
5225225RalfJung
andauthored
Code comment changes from code review
Co-authored-by: Ralf Jung <[email protected]>
1 parent 250d450 commit fd830e7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/shims/posix/sync.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
367367
// Destroying an uninit pthread_mutexattr is UB, so check to make sure it's not uninit.
368368
mutexattr_get_kind(this, attr_op)?.check_init()?;
369369

370+
// To catch double-destroys, we de-initialize the mutexattr.
370371
// This is technically not right and might lead to false positives. For example, the below
371372
// code is *likely* sound, even assuming uninit numbers are UB, but miri with
372373
// -Zmiri-check-number-validity complains
@@ -376,6 +377,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
376377
// libc::pthread_mutexattr_destroy(x.as_mut_ptr());
377378
// x.assume_init();
378379
//
380+
// However, the way libstd uses the pthread APIs works in our favor here, so we can get away with this.
379381
// This can always be revisited to have some external state to catch double-destroys
380382
// but not complain about the above code. See https://github.com/rust-lang/miri/pull/1933
381383

0 commit comments

Comments
 (0)