Program crash: GC destroys an object unexpectedly

jfondren julian.fondren at gmail.com
Tue Sep 14 14:56:00 UTC 2021


On Tuesday, 14 September 2021 at 14:40:55 UTC, eugene wrote:
> On Tuesday, 14 September 2021 at 12:09:03 UTC, Steven 
> Schveighoffer wrote:
>> This project is too big and complex
>
> Really, "too big and complex"?
> It's as simple as a tabouret :)
> It's just a toy/hobby 'project'.

A 5-pound phone isn't "too heavy" for an adult to carry but it 
won't sell well. It's not just about capabilities but what 
efforts people are willing to expend.

I would troubleshoot your issue by gradually making it @safe and 
thinking about exceptions. One exception I didn't think about 
earlier was the 'misaligned pointer' one that I said I suppressed 
just to find the next @safe complaint:

https://dlang.org/spec/garbage.html says:

>Do not misalign pointers if those pointers may point into the GC 
>heap,

So even if the lifetimes of your EventSource structs are fixed, 
the GC can reap the object they're pointing to. You could fix 
this by having a 128-bit struct and passing C an index into it, 
so to speak.


More information about the Digitalmars-d-learn mailing list