Crash with Python bindings

Justus Winter justus at sequoia-pgp.org
Fri Mar 16 05:12:26 PDT 2018


David Bremner <david at tethera.net> writes:

> "W. Trevor King" <wking at tremily.us> writes:
>
>> you can avoid the abort (which happens when q.__del__ is called after
>> db.__del__).  We could make that sort of cleanup easier with context
>> managers for Query objects (we have them for databases since [3]), and
>> they look like the only object that keep an internal database
>> reference:
>>
>>   with Database() as db:
>>     with Query(db, "*") as q:
>>       # do something with q
>>     db.close()

So while this shouldn't crash of course, this code is wrong.  The
context manager closes the database, so doing db.close() at the end of
the block is superfluous.

> I'm reminded [1] that this problem still exists. If noone has any idea
> of a fix, should we document one of the workarounds?

I don't remember the details, but the different semantics of garbage
collection and talloc was problematic.  In essence, every wrapping
Python object must keep a reference to its parent (as in parent in the
talloc hierarchy).

The bug report [1] sounds like that the crash happens at interpreter
shutdown, where iirc the objects destructors are called in arbitrary
order.


Justus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20180316/76e396ee/attachment.sig>


More information about the notmuch mailing list