Is this a bug?

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 4 03:39:48 PDT 2014


On Sunday, 4 May 2014 at 10:28:30 UTC, Mike Parker wrote:
> The current implementation of the GC will run destructors on 
> any objects still resident on the heap during termination. 
> There is no way to guarantee the order in which those 
> destructors will be run.
>
> Most likely, what you're seeing is that the LogFilter instance 
> referenced by the info template is being destroyed before the 
> destructor on CHello is run. Therefore, you're referencing an 
> invalid memory location.
>
> The short of it is that you should never touch anything on that 
> lives on the GC heap from inside a destructor -- there's no 
> guarantee that it will still be alive when your destructor is 
> run.

Really??? I knew there was no guarantee in which order the 
destructor were run, but at the very least, I thought you had a 
guarantee of dependency ordering?

...

Then again, the GC can collect cycles, so...

Well dang. That's a bummer.


More information about the Digitalmars-d-learn mailing list