digitalmars.D.bugs - [Issue 23442] New: 1 day agoDMD dll GC bug when calling a function
- d-bugmail puremagic.com (49/49) Oct 28 2022 https://issues.dlang.org/show_bug.cgi?id=23442
https://issues.dlang.org/show_bug.cgi?id=23442 Issue ID: 23442 Summary: 1 day agoDMD dll GC bug when calling a function from an interface that creates a new object Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: msnmancini hotmail.com Common code: ```d module common; interface IFont { IFont createFontWithSize(int size); } ``` Executable Code: ``` import common; class TTFFont : IFont { IFont createFontWithSize(int size){return new TTFFont;} } export extern(System) IFont newFont() { auto ret = new TTFFont(); GC.addRoot(ret); return ret; } ``` DLL Code: ``` import common; Runtime.initialize(); IFont function() newFont; newFont = loadSymbol("newFont"); IFont myFont = newFont(); //GC root ok, does not get collected IFont otherFont = myFont.createFontWithSize(32); //Gets collected after some time ``` As my object that creates another object is rooted, should not it create another rooted object? --
Oct 28 2022