if (X !is null && X.Y !is null) access crash

Amex Amex at gmail.com
Sun Jun 9 05:25:10 UTC 2019


On Saturday, 8 June 2019 at 20:44:13 UTC, Steven Schveighoffer 
wrote:
> On 6/8/19 2:28 AM, Amex wrote:
>> On Friday, 7 June 2019 at 16:09:47 UTC, Adam D. Ruppe wrote:
>>>> It happens when I close down my app.
>>>
>>> is this inside a destructor?
>> 
>> No, it's in an external thread(it is in a callback). All I can 
>> think of is that something is happening in between the two 
>> checks since there is no way it could happen otherwise.
>> 
>> 
>> 
>
> Possible the GC cleaned up the object already. When this 
> happens, you get this kind of behavior (the GC intentionally 
> sets the vtable to null to prevent invalid access).
>
> Try GC.addRef on the X reference, and see if it helps.
>
> -Steve

This is during shutdown so I imagine simply turning off the GC 
should work fine? That way it prevents all cases rather than 
having to add a bunch of specific cases each time they crop up.




More information about the Digitalmars-d-learn mailing list