On Thu, 8 Sep 2011 11:15:57 -0400, Austin Clements <amdragon@MIT.EDU> wrote: > In general, a garbage collector can't make any guarantees about > finalization order. When a collection of objects all become > unreachable simultaneously (for example, the last reference to any > Messages object is dropped, causing the Query object and the Message > object to both become unreachable), the garbage collector *could* > finalize the Query first (causing talloc to free the > notmuch_messages_t) and then the Messages object (causing it to > crash). There's no guarantee in general because, in the presence of > cycles, there is no meaningful finalization order. Right, but that should not pose a problem for python. If e.g. both a Query and derived Message objects become unreachable, the python objects would not care which object is ditched and deleted first. Currently, it seems that we finalize the Messages first, and the Query second. But we would not fail if the Query were finalized first. Granted, the underlying libnotmuch Message objects were torn away while the python Message objects were still around. But they would ultimately also be sweeped away, and that would not cause any problems. But I am sure that I am missing out something. I'll leave this discussion to the pros :-). Sebastian