Confused why this has a stack overflow and times out on play.rust


#1

Here is the code:

use std::sync::mpsc;
use std::thread;

pub enum Event {
  Data([[u32; 256]; 256]),
  Hello,
}

fn main() {
    let (tx, rx) = mpsc::sync_channel(0);
    
    thread::spawn(move || {
      tx.send(Event::Hello).unwrap();
    });
    
    rx.recv().unwrap();
    println!("done");
}

Rust play: https://is.gd/g4wbCn

If I comment out the Data enum, then this code works. Anyone know why?


#2

Data is 256KB. Presumably the playground has a stack limit configured smaller than that.


#3

Thank you. I guess I’ll need to use a reference or a Vec.