www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23442] New: 1 day agoDMD dll GC bug when calling a function


          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:

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();
  return ret;

DLL Code:
import common;

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

As my object that creates another object is rooted, should not it create
another rooted object?

Oct 28 2022