Comment #0 by renezwanenburg — 2012-01-20T08:16:08Z
We have a situation where a class has a static associative array member, which is accessed in the destructor.
If there are still instances left of this class during program shutdown, the GC deletes them and calls the destructor. At this point the static member appears to have been deleted, as any operations on the array cause the program to crash.
The aa is non-null, so checking for a null pointer doesn't work. As a workaround, it's possible to add a static destructor to the class which sets the aa to null, and check for this in the non-static destructor.
This is less than ideal, so it would be nice if it's possible to change the destruction order: First all class instances, then the static data.
Comment #1 by timon.gehr — 2012-01-20T09:19:36Z
That would break any code that accesses class instances or allocates memory from a static destructor.
Comment #2 by timon.gehr — 2012-01-20T09:27:14Z
The order of static destructors/GC is not what causes the problem: The AA is invalidated by the GC shutting down, not by a static destructor.
If the order was changed, you'd still have the issue, but your solution would not work anymore.