12-Apr-2013 18:40, Manu пишет:
Just a moment ago you were arguing for some quite different platform :)It measures in the megabytes on PC's, I'm used to working on machines
with ~32k stack, I use it aggressively, and I don't tend to run out.
Regardless - think fibers on say servers. These get no more then around 64K of stack. In fact, current D fibers have something like 16K or 32K.
There even was report that writeln triggered stack overflow with these, so the size was extended a bit.
In general simple non-GUI threads on Windows get 64K by default (IRC).
In the end if one library thinks it's fine to burn say 32K of stack
with alloca but then it calls into another one that burns another
chunk with alloca and so on untill happily stack overflowing
(sometimes, on some systems at the right time!). Call graphs to
calculate this is only available for the final app.
Maybe just adding a separate thread-local growable stack for data
would work - at least it wouldn't depend on sheer luck and
particular OS settings.
If you're saying the stack is a limited resource, therefore it's unsafe
to use it, then you might as well argue that calling any function is an
unsafe process.
s/limited/unpredictably limited/
"calling any function is an unsafe process" - indeed in principle you don't know how much of stack these use unless you measure them or analyze otherwise.
It's awful that on 32 bit system you can't expect stack to be arbitrarily long (as much as you'd use of it) due to threads quickly using up all of virtual memory. On 64-bit something to that effect is achievable
Exactly except that in the library there is no knowledge to get a measure of "common sense". It can't tell how somebody intends to use it, especially the standard library.Some common sense is required.
> I wouldn't personally burn more than 1kAnd you trust that nobody will build a ton of wrappers on top of your function (even close to leaf one)? Come on, "they" all do it.
> in a single function, unless I knew it was close to a leaf by design
> (which many library calls are).
???90% of what we're dealing with here are strings, and they tend to
measure in the 10s of bytes.
Not at all, paths could easily get longer the 256, much to legacy apps chagrin.