* [rust-dev] Newbie question about Rust stack management
@ 2014-12-18 9:40 Alfredo Di Napoli
2014-12-18 10:22 ` Richo Healey
0 siblings, 1 reply; 3+ messages in thread
From: Alfredo Di Napoli @ 2014-12-18 9:40 UTC (permalink / raw)
To: rust-dev
[-- Attachment #1: Type: text/plain, Size: 1091 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 1375 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rust-dev] Newbie question about Rust stack management
2014-12-18 9:40 [rust-dev] Newbie question about Rust stack management Alfredo Di Napoli
@ 2014-12-18 10:22 ` Richo Healey
2014-12-18 10:24 ` Alfredo Di Napoli
0 siblings, 1 reply; 3+ messages in thread
From: Richo Healey @ 2014-12-18 10:22 UTC (permalink / raw)
To: Alfredo Di Napoli; +Cc: rust-dev
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rust-dev] Newbie question about Rust stack management
2014-12-18 10:22 ` Richo Healey
@ 2014-12-18 10:24 ` Alfredo Di Napoli
0 siblings, 0 replies; 3+ messages in thread
From: Alfredo Di Napoli @ 2014-12-18 10:24 UTC (permalink / raw)
To: Richo Healey; +Cc: rust-dev
[-- Attachment #1: Type: text/plain, Size: 1721 bytes --]
Ah, thanks a lot Richo,
I did miss the fact a Box was allocating on the heap. Bad me!
Yes, I do agree that allocating huge things on the stack is bad, hence my
head scratching.
Thanks!
Alfredo
On Thursday, 18 December 2014, Richo Healey <richo@psych0tik.net> wrote:
> 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
>
[-- Attachment #2: Type: text/html, Size: 2424 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-18 10:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-18 9:40 [rust-dev] Newbie question about Rust stack management Alfredo Di Napoli
2014-12-18 10:22 ` Richo Healey
2014-12-18 10:24 ` Alfredo Di Napoli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox