diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-04-19 22:57:42 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-19 22:57:42 +0200 |
| commit | f7d8f5b1e19f0f8cb45f8085ab3a3933359aa4d5 (patch) | |
| tree | 588e9c8e8baa8ef27a7b281481791050f891e614 /src/librustdoc/html/static/js/source-script.js | |
| parent | 113f079a97ac3a1ab2fabbae274508cbcb248060 (diff) | |
| parent | 05489e7ec8ee4cdf83b819dac3de83ef6515c98a (diff) | |
| download | rust-f7d8f5b1e19f0f8cb45f8085ab3a3933359aa4d5.tar.gz rust-f7d8f5b1e19f0f8cb45f8085ab3a3933359aa4d5.zip | |
Rollup merge of #96162 - RalfJung:mark-uninit, r=oli-obk
interpret: Fix writing uninit to an allocation
When calling `mark_init`, we need to also be mindful of what happens with the relocations! Specifically, when we de-init memory, we need to clear relocations in that range as well or else strange things will happen (and printing will not show the de-init, since relocations take precedence there).
Fixes https://github.com/rust-lang/miri/issues/2068.
Here's the Miri testcase that this fixes (requires `-Zmiri-disable-validation`):
```rust
use std::mem::MaybeUninit;
fn main() { unsafe {
let mut x = MaybeUninit::<i64>::uninit();
// Put in a ptr.
x.as_mut_ptr().cast::<&i32>().write_unaligned(&0);
// Overwrite parts of that pointer with 'uninit' through a Scalar.
let ptr = x.as_mut_ptr().cast::<i32>();
*ptr = MaybeUninit::uninit().assume_init();
// Reading this back should hence work fine.
let _c = *ptr;
} }
```
Previously this failed with
```
error: unsupported operation: unable to turn pointer into raw bytes
--> ../miri/uninit.rs:11:14
|
11 | let _c = *ptr;
| ^^^^ unable to turn pointer into raw bytes
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
= note: inside `main` at ../miri/uninit.rs:11:14
```
Diffstat (limited to 'src/librustdoc/html/static/js/source-script.js')
0 files changed, 0 insertions, 0 deletions
