Program crash: GC destroys an object unexpectedly

user1234 user1234 at 12.de
Mon Sep 13 17:42:05 UTC 2021


On Monday, 13 September 2021 at 17:40:41 UTC, user1234 wrote:
> On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote:
>> [...]
>
> At first glance and given the fact that some code necessary to 
> diagnose the problem accurately is missing:
>
> `new Stopper` allocates using the GC. it's then a "GC range", 
> it's content will be scanned and handled by the GC, including 
> `sg0` and `sg1`.
>
> So far everything is simple.
>
> The problems seems to lies in `newSignal()` which "would" not 
> allocate using the GC. So when the GC reaches `sg0` and `sg1` 
> values, indirectly when scanning a `Stopper` instance, it 
> thinks that these they are unused and, consequently, free them.
>
> If you dont want them to be managed by the GC remove them from 
> the GC, using `removeRange()`.

of sorry, or maybe the opposite, so addRange...


More information about the Digitalmars-d-learn mailing list