Program crash: GC destroys an object unexpectedly

Steven Schveighoffer schveiguy at gmail.com
Tue Sep 14 12:09:03 UTC 2021


On 9/14/21 1:49 AM, Tejas wrote:
> On Monday, 13 September 2021 at 18:42:47 UTC, Steven Schveighoffer wrote:
>> On 9/13/21 1:54 PM, eugene wrote:
>>> [...]
>>
>> The GC only scans things that it knows about.
>>
>> Inside your EventQueue you have this code:
>>
>> [...]
> 
> Umm is it okay that he declared variables `init` and `idle` of type 
> `Stage` inside the constructor? Maybe that has something to do with 
> this? Also, calling a variable `init` could be problematic since the 
> compiler assigns a property of the same name to every single type?

Declaring a member/field named `init` is likely a bad idea, but this is 
not a member, it's just a variable. That's fine. `idle` doesn't mean 
anything special to D.

This project is too big and complex for me to diagnose by just reading, 
it would take some effort, and I don't have the time, sorry. Though as I 
have learned helping C converts before, most of the time things like 
this have to do with forgetting to store a GC reference somewhere. It 
can be subtle too...

I still recommend pinning the object when adding the epoll event and 
seeing if that helps.

-Steve


More information about the Digitalmars-d-learn mailing list