[Issue 21067] New: Tupleof of struct returned by function with string field lazily passed to function, itself lazily passed to another function, causes runtime OOM.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 23 15:35:20 UTC 2020


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

          Issue ID: 21067
           Summary: Tupleof of struct returned by function with string
                    field lazily passed to function, itself lazily passed
                    to another function, causes runtime OOM.
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: default_357-line at yahoo.de

Consider the following, remarkable code:

struct S { int b; string s; }

S test() { return S(); }

void main()
{
    evalArg(dupArg2(test.tupleof));
}

void dupArg2(int, lazy string msg)
{
    msg().dup;
}

void evalArg(lazy void expression)
{
    try expression();
    finally { }
}

When built and run with DMD, I get an OOM error.

LDC gives the somewhat more helpful error:

test.d(7): Error: function test.main.__dgliteral1 cannot access frame of
function test.main.__dgliteral2

For the evalArg call. Indicating the issue is related to the double-nesting of
lazy.

--


More information about the Digitalmars-d-bugs mailing list