-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-target-specsArea: Compile-target specificationsArea: Compile-target specificationsC-bugCategory: This is a bug.Category: This is a bug.E-needs-investigationCall for partcipation: This issues needs some investigation to determine current statusCall for partcipation: This issues needs some investigation to determine current statusI-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-linuxOperating system: LinuxOperating system: LinuxO-windows-gnuToolchain: GNU, Operating system: WindowsToolchain: GNU, Operating system: WindowsO-windows-msvcToolchain: MSVC, Operating system: WindowsToolchain: MSVC, Operating system: WindowsP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Example code:
#[repr(align(0x100000))]
struct Aligned(u8);
static X: Aligned = Aligned(0);
fn main() {
let x = Aligned(0);
println!("{:#x}", &x as *const _ as usize);
println!("{:#x}", &X as *const _ as usize);
println!("{:#x}", Box::into_raw(Box::new(Aligned(0))) as usize);
}
Output:
0x7ffec8000000
0x55c9b2596000
0x7f2879f00000
I am not sure about other platforms, but in the case of Linux this happens because the ELF loader in the kernel ignores the p_align
field of the ELF program headers and assumes page-alignment instead.
Metadata
Metadata
Assignees
Labels
A-alignArea: alignment control (`repr(align(N))` and so on)Area: alignment control (`repr(align(N))` and so on)A-target-specsArea: Compile-target specificationsArea: Compile-target specificationsC-bugCategory: This is a bug.Category: This is a bug.E-needs-investigationCall for partcipation: This issues needs some investigation to determine current statusCall for partcipation: This issues needs some investigation to determine current statusI-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-linuxOperating system: LinuxOperating system: LinuxO-windows-gnuToolchain: GNU, Operating system: WindowsToolchain: GNU, Operating system: WindowsO-windows-msvcToolchain: MSVC, Operating system: WindowsToolchain: MSVC, Operating system: WindowsP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.