Accessing an object after it has been unlinked by the cycle collector is a certain way to cause trouble. Usually, that trouble is just in the form of null pointer crashes, but it can potentially be much worse. And the most common cause of those types of issues comes from accessing a weak pointer for an object after it has been unlinked, but before it has been finalized. The solution to that entire class of problem is to always clear weak references to an object when it is unlinked.

Bug 1535617 adds some helper macros for this (NS_IMPL_CYCLE_COLLECTION_UNLINK_WEAK_REFERENCE and NS_IMPL_CYCLE_COLLECTION_UNLINK_WEAK_PTR, along with some other convenience macros along the lines of NS_IMPL_CYCLE_COLLECTION(...)), and fixes most existing classes which implement both cycle collection and weak references. Any new such classes will need to do the same.

Thanks,
Kris
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to