http://d.puremagic.com/issues/show_bug.cgi?id=5176
--- Comment #15 from bearophile_h...@eml.cc 2013-01-09 18:30:05 PST --- (In reply to comment #13) > Very large structs can also corrupt memory not just via null references, but > via stack overflow. (Just pass a large struct by value down a few levels of > recursion, and the stack will overflow.) And it's easier than one might think: > > struct S { > dchar[256] buffer; > } > > Looks small, right? Well, sizeof(dchar)=4, which means sizeof(S)=1024. On > Linux, the default stacksize is about 4KB. That means passing S by value down > just 3-4 levels of recursion is enough to overflow the stack. A 1 kb struct should be considered very little for the stack. Generally it's a good idea to use the stack in D, because it avoids many slow heap allocations and decreases pressure on the GC. On a modern PC with 1 GB RAM a D programmer should be free to use 1-10 MB of RAM for the stack. On Windows there is a linker command to increase the stack size. > And currently, I > don't think DMD does any handling for stack overflow; it just crashes (and may > corrupt memory as well, I didn't look into it). DMD used to give a readable error message on Windows, but now programs just crash. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------