-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.O-SPARCTarget: SPARC processorsTarget: SPARC processorsT-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
The function extract_bytecode_format_version()
in rustc_trans::back::lto
is consistently crashing with a SIGBUS
on SPARC when compiling Firefox. I'm seeing pos
set to 11, and the code generated for the coercion in the unsafe
statement isn't intelligent enough to deal with the lack of alignment.
The reduced testcase is simple:
fn main() {
let arr: [u8; 8] = [0; 8];
let byte_data = &arr[1..5];
let data = unsafe { *(byte_data.as_ptr() as *const u32) };
u32::from_le(data);
}
I can fix that with a copy_from_slice()
:
let mut byte_data: [u8; 4] = [0; 4];
byte_data.copy_from_slice(&bc[pos..pos + 4]);
but I don't know if there's a more idiomatic way, and I don't know how best to make sure that on architectures that can handle the one-byte alignment, it skips the copy.
I suspect that extract_compressed_bytecode_size_v1()
has a similar issue.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.O-SPARCTarget: SPARC processorsTarget: SPARC processorsT-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.