Bug 23442 – DMD DLL GC bug when calling a function from an interface that creates a new object

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2022-10-28T19:53:51Z
Last change time
2024-12-13T19:25:16Z
Keywords
dll
Assigned to
No Owner
Creator
Marcelo Silva Nascimento Mancini
Moved to GitHub: dmd#18132 →

Comments

Comment #0 by msnmancini — 2022-10-28T19:53:51Z
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?
Comment #1 by robert.schadek — 2024-12-13T19:25:16Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18132 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB