Repository navigation
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationArea: Code generationC-bugCategory: This is a bug.Category: This is a bug.I-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/SoundnessP-highHigh priorityHigh priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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.WG-llvmWorking group: LLVM backend code generationWorking group: LLVM backend code generation
Description
code from tests/ui/foreign/foreign-truncated-arguments.rs
// run-pass
// compile-flags: -O
// Regression test for https://github.com/rust-lang/rust/issues/33868
#[repr(C)]
pub struct S {
a: u32,
b: f32,
c: u32
}
#[no_mangle]
#[inline(never)]
pub extern "C" fn test(s: S) -> u32 {
s.c
}
fn main() {
assert_eq!(test(S{a: 0, b: 0.0, c: 42}), 42);
}When checked with rustc -Cpasses=lint src/test/ui/foreign/foreign-truncated-arguments.rs, this generates the following llvm-ir lint warning:
Undefined behavior: Buffer overflow
%13 = load { i64, i32 }, { i64, i32 }* %12, align 4
repo @ 2342cc3
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationArea: Code generationC-bugCategory: This is a bug.Category: This is a bug.I-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/SoundnessP-highHigh priorityHigh priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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.WG-llvmWorking group: LLVM backend code generationWorking group: LLVM backend code generation
Activity
cuviper commentedon Aug 24, 2020
I captured the LLVM-IR in a single codegen unit, then ran
opt -lintwhich has the same complaint, just on%4.Here are the relevant snippets from that IR:
I expect
Shas size 12, but{ i64, i32 }would have alignment padding up to size 16.The lint goes away if I change all
{ i64, i32 }to packed<{ i64, i32 }>, but maybe we can do better than that.mmastrac commentedon Apr 13, 2024
We've been working on enabling ASAN in rusty_v8 (https://github.com/denoland/rusty_v8) and we suspect this is causing some real-world bugs when we call into V8 from Rust. In particular, some exceptions in V8 aren't correctly detected when we compile the Rust parts with opt-level=0.
apiraino commentedon Apr 15, 2024
WG-prioritization assigning priority (Zulip discussion).
@rustbot label -I-prioritize +P-high
dianqk commentedon Jun 30, 2024
{ i64, i32 }should have 16 bytes on x86_64.@rustbot claim
Auto merge of rust-lang#127168 - DianQK:cast-size, r=workingjubilee
Rollup merge of rust-lang#127168 - DianQK:cast-size, r=workingjubilee
Unrolled build for rust-lang#127168
apiraino commentedon Jul 3, 2024
reopening to follow the beta backport of #127168
dianqk commentedon Jul 4, 2024
@mmastrac Can you reproduce the problem on the latest nightly? I can't confirm that #127168 has fixed it.
dianqk commentedon Jul 5, 2024
@apiraino We can close it again.