From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 4C7406DE5ED7 for ; Fri, 16 Mar 2018 05:12:35 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.649 X-Spam-Level: X-Spam-Status: No, score=-0.649 tagged_above=-999 required=5 tests=[AWL=0.050, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4ETVNgWbyvij for ; Fri, 16 Mar 2018 05:12:34 -0700 (PDT) Received: from avior.uberspace.de (avior.uberspace.de [185.26.156.32]) by arlo.cworth.org (Postfix) with ESMTPS id BA7486DE5CEC for ; Fri, 16 Mar 2018 05:12:32 -0700 (PDT) Received: (qmail 21494 invoked from network); 16 Mar 2018 12:12:28 -0000 Received: from localhost (HELO europa) (127.0.0.1) by avior.uberspace.de with SMTP; 16 Mar 2018 12:12:28 -0000 Received: from teythoon by europa with local (Exim 4.90_1) (envelope-from ) id 1ewoDi-0005v9-Gr; Fri, 16 Mar 2018 13:12:26 +0100 From: Justus Winter To: David Bremner , "W. Trevor King" Cc: notmuch@notmuchmail.org Subject: Re: Crash with Python bindings In-Reply-To: <87k1ucp6xb.fsf@tethera.net> References: <5694CA65.8010400@fastmail.net> <20160112102329.4269.20741@thinkbox.jade-hamburg.de> <20160112185107.GA21580@odin.tremily.us> <87k1ucp6xb.fsf@tethera.net> Date: Fri, 16 Mar 2018 13:12:26 +0100 Message-ID: <87r2ok8bit.fsf@europa.jade-hamburg.de> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Mar 2018 12:12:35 -0000 --=-=-= Content-Type: text/plain David Bremner writes: > "W. Trevor King" 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 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEJWpOVeSnLZetJGjniNx+MzhfeR0FAlqrtKoACgkQiNx+Mzhf eR3FywgAtUW2ovwes1ba58Xwchvv7m+phmWT89ePwX6syfCQXQNWATXIOsP3n1Nj L3SHh7ua75kYCvD4npkDnFwlAqNilf4QuzEiEB6fJNnyGxqC5s9/wgg9LzP1nADr 31btc26sO2S97rMbnM/2FCoboh5ReYIXhUuBMkFOgid7akEP15e4glGRv6Zqu5p3 3Hp5TvX+ZkwRaQm8joEFx9zVp1vqaDgCQy/lO1CXevgt1yWANrTthx3fpkguABox TbWRtafWPUFbeP87bXS1KPhjXf18WVuT6tj6SqNHWUbwhobwuefZ04FJArB1+WXB 8vQIeLpwrzgEd7NTZhDnn+MW0QqHbg== =j0WX -----END PGP SIGNATURE----- --=-=-=--