On 18/12/14 10:40 +0100, Alfredo Di Napoli wrote:
Good morning Rustaceans,

I'm just moving my first steps into the Rust world, so please apologies in
advance for my silly questions.
As an exercise to learn the language I'm trying to create a streaming CLI
app to decrypt data read from stdin
directly into stdout.
This gist is a very simple program to simply read raw bytes from stdin and
pushing them out to stdout:

https://gist.github.com/adinapoli/da8cc9cbaec3576a1bd4

It works, but as soon as I try to modify the BUFSIZE to be, for example,
5MB, the program crashes with:

task '<main>' has overflowed its stack

I have tried to Google for "rust increase stack size", but I wasn't able to
find anything meaningful.
I would like to ask you then if this is just because I failed to search the
relevant bits of documentation, or it's "by design" because it's a bad idea
to increase the stack size? This bit of documentation seems relevant,
although it refers to "task" (but main seems to be indeed one), and returns
a TaskBuilder:

http://doc.rust-lang.org/std/task/struct.TaskBuilder.html#method.stack_size

Thanks in advance,

Alfredo

The easiest thing to do here is simply to lob it onto the heap, by putting it
into a box:

https://gist.github.com/0a324ac17620bf0ac286

In general, you probably don't want huge objects on the stack.

richo
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to