-
Notifications
You must be signed in to change notification settings - Fork 392
Closed
rust-lang/rust
#129778Labels
A-interpreterArea: affects the core interpreterArea: affects the core interpreterA-validationArea: This affects enforcing the validity invariant, and related UB checkingArea: This affects enforcing the validity invariant, and related UB checkingC-bugCategory: This is a bug.Category: This is a bug.I-misses-UBImpact: makes Miri miss UB, i.e., a false negative (with default settings)Impact: makes Miri miss UB, i.e., a false negative (with default settings)
Description
Miri should be able to detect that the following is UB because it prints uninitialized memory:
use std::mem;
#[repr(C)]
struct Pair(u8, u16);
fn main() { unsafe {
let p: Pair = mem::transmute(0u32); // The copy when `Pair` is returned from `transmute` should destroy padding.
let c = &p as *const _ as *const u8;
println!("{}", *c.add(1)); // Print the padding byte.
} }
However, currently assignment is just implemented as an untyped memcpy
, so we incorrectly preserve padding.
gnzlbg and DianaNites
Metadata
Metadata
Assignees
Labels
A-interpreterArea: affects the core interpreterArea: affects the core interpreterA-validationArea: This affects enforcing the validity invariant, and related UB checkingArea: This affects enforcing the validity invariant, and related UB checkingC-bugCategory: This is a bug.Category: This is a bug.I-misses-UBImpact: makes Miri miss UB, i.e., a false negative (with default settings)Impact: makes Miri miss UB, i.e., a false negative (with default settings)