www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21097] New: [REG2.083] Stack exhaustion upon large struct

https://issues.dlang.org/show_bug.cgi?id=21097

          Issue ID: 21097
           Summary: [REG2.083] Stack exhaustion upon large struct .destroy
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: johanengelen weka.io

Testcase:
```
import std.stdio;

struct S {
 // doesn't have to be this large to exhaust the stack of course
    ubyte[10_000_000] i = [1,2];

    void close() { destroy(this); }
}

void main() {
   auto s = new S();
   s.close(); 
}
```

The problem is that the instantiated druntime template to write S.init to the
object uses a stack allocated temporary with the same size as the object -->
stack exhaustion. Prior versions used a global statically allocated variable
and thus did not have the problem. (but there was duplication of data)

There's been a lot of work on the object.destroy code for structs, I can't
trace back history easily.
What works: LDC 1.13.0 (dlang 2.083.1)
What doesn't: LDC 1.14 (dlang 2.084)

--
Jul 30 2020