[Issue 23442] New: 1 day agoDMD dll GC bug when calling a function from an interface that creates a new object
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 28 19:53:51 UTC 2022
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 at puremagic.com
Reporter: msnmancini at 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?
--
More information about the Digitalmars-d-bugs
mailing list