Bug 21067 – Tupleof of struct returned by function with string field lazily passed to function, itself lazily passed to another function, causes runtime OOM.

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2020-07-23T15:35:20Z
Last change time
2024-12-13T19:10:18Z
Assigned to
No Owner
Creator
FeepingCreature
Moved to GitHub: dmd#19750 →

Comments

Comment #0 by default_357-line — 2020-07-23T15:35:20Z
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.
Comment #1 by default_357-line — 2020-07-23T15:41:07Z
A shorter version that "runs" with dmd, but preserves the ldc error: struct S { int a; int b; } S test() { return S(); } void main() { evalArg(dupArg2(test.tupleof)); } void dupArg2(int, lazy int) {} void evalArg(lazy void) {}
Comment #2 by robert.schadek — 2024-12-13T19:10:18Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19750 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB