miri weak memory emulation: put previous value into initial store buffer
Fixes https://github.com/rust-lang/miri/issues/2164 by doing a read before each atomic write so that we can initialize the store buffer. The read suppresses memory access hooks and UB exceptions, to avoid otherwise influencing the program behavior. If the read fails, we store that as None in the store buffer, so that when an atomic read races with the first atomic write to some memory and previously the memory was uninitialized, we can report UB due to reading uninit memory.
@cbeuw this changes a bit the way we initialize the store buffers. Not sure if you still remember all this code, but if you could have a look to make sure this still makes sense, that would be great. :)
r? @saethlin
The Miri subtree was changed
cc @rust-lang/miri
Some changes occurred to the CTFE / Miri engine
cc @rust-lang/miri
@saethlin how should we proceed here? Is there some way I can make reviewing simpler? Should we look for another reviewer?
Most of this is in Miri where I'd probably self-approve based on @cbeuw having taken a look, but we do need to make a function in rustc public to make this work which is why this became a rustc PR.
I'll review this today, that's how we will proceed :p
:-)
I have a question about the implementation, but it's just idle curiosity. Thanks for the reminder.
@bors r+
:pushpin: Commit 8b18c6bdd3d61dda5fe8c4ed378286abec2a9bc4 has been approved by saethlin
It is now in the queue for this repository.