The problem is the huge allocation(s) you're trying to do: the vec::from_elem
call in simple_sieve
is trying to allocate 600851475143/2
bytes, i.e. approximately 280 GB. The allocation is failing (i.e. malloc
returns NULL) which ATM just causes Rust to abort.
This simpler program indicates the problem:
extern crate libc;
fn main() {
let n = 600851475143 / 2;
let p = unsafe {libc::malloc(n as libc::size_t)};
println!("alloc {}", p)
}
prints alloc 0x0
for me. Try using smaller numbers. :)