Refer to GitHub issue on overwritten init value

This commit is contained in:
Andy Wang 2022-05-29 19:48:36 +01:00
parent 4a07f78dad
commit 8215702d5a
No known key found for this signature in database
GPG Key ID: 181B49F9F38F3374
4 changed files with 3 additions and 2 deletions

View File

@ -544,6 +544,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriEvalContextExt<'mir, 'tcx> {
// side effects from a read the program did not perform. So we have to initialise
// the store buffer with the value currently being written
// ONCE this is fixed please remove the hack in buffered_atomic_write() in weak_memory.rs
// https://github.com/rust-lang/miri/issues/2164
this.buffered_atomic_write(val, dest, atomic, val)
}

View File

@ -508,6 +508,7 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
// UGLY HACK: in write_scalar_atomic() we don't know the value before our write,
// so init == val always. If the buffer is fresh then we would've duplicated an entry,
// so we need to remove it.
// See https://github.com/rust-lang/miri/issues/2164
let was_empty = matches!(
alloc_buffers
.store_buffers

View File

@ -638,8 +638,6 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'mir, 'tcx> {
None
};
let buffer_alloc = if ecx.machine.weak_memory {
// FIXME: if this is an atomic obejct, we want to supply its initial value
// while allocating the store buffer here.
Some(weak_memory::AllocExtra::new_allocation())
} else {
None

View File

@ -25,6 +25,7 @@ fn reads_value(loc: &AtomicUsize, val: usize) -> usize {
fn static_atomic(val: usize) -> &'static AtomicUsize {
let ret = Box::leak(Box::new(AtomicUsize::new(val)));
// A workaround to put the initialization value in the store buffer.
// See https://github.com/rust-lang/miri/issues/2164
ret.load(Relaxed);
ret
}