You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a little snippet to show the problem. Since I updated to the latest rustc I don't get a full crash report, so this is all I got.
use std::io;
fn main() {
let mut b = io::BufReader::new(b"Hello world!");
//let r = b.read_exact(2000000000000); //<-- Works as expected, prints error "end of file"
let r = b.read_exact(200000000000000); //<-- When input way too large it causes a crash
match r {
Ok(_) => (),
Err(e) => println!("{}", e)
}
}
read_exact allocates a Vec to store the data it returns. Your OS is not willing to allocate 200 terabytes of memory, which causes the program to abort.
This is working as intended. Printing an error instead of just aborting is covered by #14674. There's currently no better way to deal with this short of bubbling up out-of-memory errors everywhere.
Here's a little snippet to show the problem. Since I updated to the latest rustc I don't get a full crash report, so this is all I got.
rustc 0.13.0-nightly (8bca470 2014-12-08 00:12:30 +0000)
binary: rustc
commit-hash: 8bca470
commit-date: 2014-12-08 00:12:30 +0000
host: x86_64-apple-darwin
release: 0.13.0-nightly
OS: Mac OS X 10.9.4
The text was updated successfully, but these errors were encountered: