http://d.puremagic.com/issues/show_bug.cgi?id=5176



--- Comment #14 from deadalnix <deadal...@gmail.com> 2013-01-09 17:41:47 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. 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).

A page is reserved after the stack to detect it I think. It require to limit
the size of what can be put on stack in a single operation. Or to add the
checks that matter.

But a better option IMO is to reserve an insane amount of memory space for
fiber's stack (and then some page to be protected for stack overflow detection)
and run everything within a fiber. This is not very 32 bits compliant, but can
work really well on 64bits systems.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to