Thread overview
[Issue 21097] [REG2.083] Stack exhaustion upon large struct .destroy
July 30 changed:

           What    |Removed                     |Added
           Keywords|                            |industry

July 30

--- Comment #1 from ---
Note: the 10MB symbol may lead one to believe that this is only a problem in rare cases. It isn't. At Weka, this bug is triggered with a dynamically allocated 300kb struct. Fibers do not have very large stacks.

July 31

--- Comment #2 from ---
Two potential solutions:
// Avoid stack allocation, at the cost of virtual call to get the init symbol.
    auto arr = cast(ubyte[])typeid(T).initializer();
    if (arr.ptr is null) {
        (cast(ubyte*)val)[0 .. T.sizeof] = ubyte(0);
    } else {
        // Use fill to duplicate 'arr' to work around
        (cast(ubyte*)val)[0 .. T.sizeof].fillbytes(arr);

// Avoid stack allocation, at the cost of duplicating the init symbol (binary
size increase)
    import core.stdc.string : memcpy;
    shared static immutable T init = T.init;
    memcpy(&chunk, &init, T.sizeof);

(one cannot access the init symbol directly)