-
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
VecDeque from Vec fails with ZST #78532
Comments
I can reproduce when using Miri, but it works fine for me with WASM: $ cargo +stable build --target=wasm32-unknown-unknown
Compiling rust-issue-78532 v0.1.0 (/Users/user/rust-issue-78532)
Finished dev [unoptimized + debuginfo] target(s) in 0.17s (Same with nightly toolchain.) |
use std::collections::VecDeque;
fn main() {
let v = vec![(); 100];
let queue = VecDeque::from(v);
println!("{:?}", queue);
} panics with
it always fails here because |
Why is this specific to ZSTs? |
|
Assigning |
Currently on playground it seems to work fine both under Miri and regular rustc? Indeed something would be very wrong if it only panicked on Miri... @lcnr's version panics both with rustc and Miri. Maybe the example in the OP should be updated. |
Yes, though at time of posting it did fail under miri (and only under miri) on the playground.
Sorry if I was unclear; I meant that I got the same panic when running the built WASM. |
My guess is that something in libstd changed to fix the panic for your case (but not for @lcnr's), and when you tested this, Miri was broken in the latest toolchain so playground had an older version of Miri. When this happens again, please note down the exact versions of every component involved, so we can make sure this is comparing Miri and rustc for the same toolchain, not two different versions of Rust. |
The originally reported panic is an overflow check and one of those that is not inherited cross-crate. To observe it the standard library must be built with overflow checks. It's still an issue right now. |
Ah, so this stopped to fail in Miri when we recently stopped building libstd with debug assertions. |
…on-panic, r=dtolnay Fix overflow when converting ZST Vec to VecDeque ```rust let v = vec![(); 100]; let queue = VecDeque::from(v); println!("{:?}", queue); ``` This code will currently panic with a capacity overflow. This PR resolves this issue and makes the code run fine. Resolves rust-lang#78532
…on-panic, r=dtolnay Fix overflow when converting ZST Vec to VecDeque ```rust let v = vec![(); 100]; let queue = VecDeque::from(v); println!("{:?}", queue); ``` This code will currently panic with a capacity overflow. This PR resolves this issue and makes the code run fine. Resolves rust-lang#78532
…on-panic, r=dtolnay Fix overflow when converting ZST Vec to VecDeque ```rust let v = vec![(); 100]; let queue = VecDeque::from(v); println!("{:?}", queue); ``` This code will currently panic with a capacity overflow. This PR resolves this issue and makes the code run fine. Resolves rust-lang#78532
…on-panic, r=dtolnay Fix overflow when converting ZST Vec to VecDeque ```rust let v = vec![(); 100]; let queue = VecDeque::from(v); println!("{:?}", queue); ``` This code will currently panic with a capacity overflow. This PR resolves this issue and makes the code run fine. Resolves rust-lang#78532
…on-panic, r=dtolnay Fix overflow when converting ZST Vec to VecDeque ```rust let v = vec![(); 100]; let queue = VecDeque::from(v); println!("{:?}", queue); ``` This code will currently panic with a capacity overflow. This PR resolves this issue and makes the code run fine. Resolves rust-lang#78532
…on-panic, r=dtolnay Fix overflow when converting ZST Vec to VecDeque ```rust let v = vec![(); 100]; let queue = VecDeque::from(v); println!("{:?}", queue); ``` This code will currently panic with a capacity overflow. This PR resolves this issue and makes the code run fine. Resolves rust-lang#78532
…on-panic, r=dtolnay Fix overflow when converting ZST Vec to VecDeque ```rust let v = vec![(); 100]; let queue = VecDeque::from(v); println!("{:?}", queue); ``` This code will currently panic with a capacity overflow. This PR resolves this issue and makes the code run fine. Resolves rust-lang#78532
This code panics under Miri, and also when I compile to WASM, though not when running normally.
Playground
The overflow is here:
rust/library/alloc/src/collections/vec_deque.rs
Line 3236 in a53fb30
The text was updated successfully, but these errors were encountered: