Closed
Description
I tried this code:
use std::sync::mpsc::*;
struct BigStruct {
_data: [u32; 32000],
}
fn main() {
let thread = std::thread::spawn(move || {
let (_sender, receiver) = channel::<BigStruct>();
for _data in receiver.try_iter() {
}
});
thread.join().unwrap();
println!("Done :)");
}
I expected to see this happen:
The program shouldn't do much beside printing a friendly message.
Instead, this happened:
When running in Debug mode, the program crashes due to a stack overflow. In release mode it behaves as expected. Looping over the data in the receiver in combination with being on a separate thread triggers it.
I tried running on nightly too, which produces the same results.
I've now switched to crossbeam as a workaround, which does not suffer from the same issue fortunately.
rustc --version --verbose
:
rustc 1.64.0 (a55dd71d5 2022-09-19)
binary: rustc
commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52
commit-date: 2022-09-19
host: x86_64-pc-windows-msvc
release: 1.64.0
LLVM version: 14.0.6
Backtrace
thread '<unknown>' has overflowed its stack