-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
ICE when using Box<T, A> with non-zero sized A #78459
Comments
This ice is still showing up in |
Vec is not affected by this, and can even be used to get a Box. #![feature(allocator_api)]
fn main(){
let vec = Vec::new_in(&std::alloc::Global);
let _: Box<[()], _> = vec.into_boxed_slice();
} This code did not ICE on playground. |
@drmeepster Interestingly, trying to print the Box created in that way gives the same ICE as #81270 #![feature(allocator_api)]
fn main(){
let vec = Vec::new_in(&std::alloc::Global);
let a: Box<[()], _> = vec.into_boxed_slice();
println!("{:?}", a);
}
|
Hello, By ref: let my_allocator = unsafe { Locked::new(Heap::new(0xc00000 as *const usize, false)) };
let a = Box::new_in(42usize, &my_allocator); Produce the following:
Without ref: let my_allocator = unsafe { Locked::new(Heap::new(0xc00000 as *const usize, false)) };
let a = Box::new_in(42usize, my_allocator); Cause:
Where |
I'm hitting this issue too, on code that basically equates to this:
Seems like there are plenty of ways to reproduce this in here, but if a minimal test case is needed, I would be happy to try to provide one. I just made a repro, wasn't really that tricky. |
As far as I understand it, the issue is as follows:
|
It seems that @glandium is the one that developed the feature, in #58457. @glandium can you give us more information about the problem you faced, the workaround you choose, any hint for why it isn't working, and maybe give us possible path to explore ? |
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
While working on #77438, I've run into the following ICE.
It seems to be caused by the type layout code not expectingOn further consideration, the issue also appears withBox
to have more than 3 fields, in this case the fat pointer containing two fields, plus theAllocRef
instance.Box<T, A>
as long asA
is non zero sized.This ICE was likely not encountered during testing of #77187 because in the case of
Box<T, Global>
,Global
is zero sized. In the example below, removing the borrow ofGlobal
will cause the compilation to succeed.@eddyb could you take a look at this? :)
cc @TimDiekmann you may run into this as well on
RawVec
Code
Old code
Playground link
New, more minimal code
Playground link
Meta
rustc --version --verbose
:Error output
rust/compiler/rustc_middle/src/ty/layout.rs
Line 2056 in 07e968b
Backtrace
From playground
The text was updated successfully, but these errors were encountered: