-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Box<T, &A>
and LTO: Explicit gep type does not match pointee type of pointer operand
#95036
Comments
@rustbot modify labels: +A-allocators +A-lto |
@rustbot claim |
1 similar comment
@rustbot claim |
Hey @drmeepster thanks for looking into this bug (and for fixing my last reports as well :)). I'm able to reproduce the bug in a single crate when compiling with pub fn test() {
let mut node = Box::new_in([5u8], &Global);
node[0] = 7u8;
black_box(node);
} The bug seems to be specifically triggered when the allocator is non zero-sized, it doesn't matter whether it's a reference or not. Attempting to disassemble the bitcode dumped with The offending store instruction is encoded as follows: %17 = getelementptr inbounds [1 x i8], ptr %11, i64 0, i64 0, !dbg !919
store i8 7, ptr %17, align 1, !dbg !919 Unfortunately the Using the following which doesn't trigger the issue: pub fn test() {
let mut node = Box::new_in([5u8], Global);
node[0] = 7u8;
black_box(node);
}
%13 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0, !dbg !632
store i8 7, i8* %13, align 1, !dbg !632 |
Thanks for the info and minimized code! That's gonna make this easier. |
I still don't know how this actually happens, I just know that the change in #95328 fixes it. I suspect it's some code assuming that a wide box is always a wide pointer, but I don't know where... |
I think you're right about that assumption, using a wide pointer in the box has no issues: pub fn test_l3(mut node: Box<[u8], &Global>) {
node[0] = 7;
black_box(node);
} |
BTreeMap: Support custom allocators (v1.5) Related: rust-lang/wg-allocators#7 https://github.com/TimDiekmann/alloc-wg Blocked on: ~~rust-lang#77187~~ ~~rust-lang#78459~~ ~~rust-lang#95036~~ previous: rust-lang#77438
BTreeMap: Support custom allocators (v1.5) Related: rust-lang/wg-allocators#7 https://github.com/TimDiekmann/alloc-wg Blocked on: ~~rust-lang#77187~~ ~~rust-lang#78459~~ ~~rust-lang#95036~~ previous: rust-lang#77438
BTreeMap: Support custom allocators (v1.5) Related: rust-lang/wg-allocators#7 https://github.com/TimDiekmann/alloc-wg Blocked on: ~~rust-lang#77187~~ ~~rust-lang#78459~~ ~~rust-lang#95036~~ previous: rust-lang#77438
Code
Only when building with
lto = thin
orlto = fat
do I trigger this issue. Found while working on #77438.Compile test that triggers the issue: exrook@b2652ba
lto_box_allocator/lib.rs
box_consumer/main.rs
Meta
rustc --version --verbose
:Error output
lto=thin
lto=fat
The text was updated successfully, but these errors were encountered: