PassMode::Cast results in LLVM IR with out of bounds loads #122617
Labels
A-FFI
Area: Foreign function interface (FFI)
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
P-high
High priority
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: No UB.
Instead, this happened: https://godbolt.org/z/bd8MT4bEM
There are two problems here, first:
...we load 8 bytes from a 4 byte alloca. Alive2 believes this is UB: https://alive2.llvm.org/ce/z/eBaekz.
Second:
...only 4 bytes of
%0
are marked live, but we access 8 bytes. The langref is not clear about what the size arguments of lifetime intrinsics actually do, but this is probably UB. (Alive2 ignores the size arguments, so it can't detect this.)@rustbot label I-unsound A-ffi
This was uncovered via #122053 (comment), where this issue is the root cause of a miscompilation. That comment contains a bit more context.
Meta
rustc --version --verbose
:(also reproducible on very recent master 766bdce)
The text was updated successfully, but these errors were encountered: