Program crash in vector initialization: crash in extend_with
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
let mut drv = Vec::<[[f64; 512]; 512]>::new();
drv.resize(4, [[0.0; 512]; 512]);
Only in Debug.
I expected to see this happen:
Not crash. I'd be ok with an assert or something.
Instead, this happened:
thread 'main' has overflowed its stack
fatal runtime error: stack overflow, aborting
zsh: IOT instruction (core dumped) cargo run
Meta
rustc --version --verbose:
rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.7
Playground link
(updated, it was the wrong version)
Using vec![] instead of the Vec::new() and resize() cause the same error. (see Playground)
Happens with nightly
rustc 1.91.0-nightly (fe5536432 2025-08-29) (from rustc 1.91.0-nightly (809200ec9 2025-08-24))
Backtrace
No more info with RUST_BACKTRACE=1
With GDB
Program received signal SIGSEGV, Segmentation fault.
0x0000555555559d51 in alloc::vec::Vec<[[f64; 512]; 512], alloc::alloc::Global>::extend_with<[[f64; 512]; 512], alloc::alloc::Global> (
self=0x0, n=0, value=...)
at /var/home/hub/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:3191
3191 fn extend_with(&mut self, n: usize, value: T) {
(gdb) where
#0 0x0000555555559d51 in alloc::vec::Vec<[[f64; 512]; 512], alloc::alloc::Global>::extend_with<[[f64; 512]; 512], alloc::alloc::Global> (
self=0x0, n=0, value=...)
at /var/home/hub/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:3191
#1 0x000055555555a10d in alloc::vec::Vec<[[f64; 512]; 512], alloc::alloc::Global>::resize<[[f64; 512]; 512], alloc::alloc::Global> (
self=0x7fffffdfcca8, new_len=4, value=<error reading variable: value requires 2097152 bytes, which is more than max-value-size>)
at /var/home/hub/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:3071
#2 0x000055555555a336 in test_rust::main () at src/main.rs:10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Playground example, then inspect alloc/src/vec/mod.rs around Vec::resize and extend_with. Determine why the large array value causes a debug stack overflow and define the expected failure behavior; add regression coverage and verify the example no longer aborts unexpectedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100