1 Return-Path: <bgamari.foss@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 57A0B431FB6
\r
6 for <notmuch@notmuchmail.org>; Sun, 11 Sep 2011 14:47:49 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id Qs6EwthdpVYV for <notmuch@notmuchmail.org>;
\r
17 Sun, 11 Sep 2011 14:47:48 -0700 (PDT)
\r
18 Received: from mail-vw0-f44.google.com (mail-vw0-f44.google.com
\r
19 [209.85.212.44]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id BACE8429E21
\r
22 for <notmuch@notmuchmail.org>; Sun, 11 Sep 2011 14:47:48 -0700 (PDT)
\r
23 Received: by vws12 with SMTP id 12so2829483vws.3
\r
24 for <notmuch@notmuchmail.org>; Sun, 11 Sep 2011 14:47:47 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=from:to:cc:subject:in-reply-to:references:user-agent:date
\r
27 :message-id:mime-version:content-type;
\r
28 bh=TKAtd3qeroIGcutLccDGPMqBDsvS7d6ea0SAL3Wd8Os=;
\r
29 b=gxJZeJtWKrPGWaZO6xckhZol+0BjDu/1/JJ35mB4krDEXR63L4oCEMz7K0Iarn54jh
\r
30 E28sOMEb9GuBY2aLXEQPH7lvsvWIwVAqNyO3xybpY1skWhAqkP+eLYLrP4o1vPgEg/Wy
\r
31 F7aqo/fKdJG12hQbReZwo+UyIEqmw1M1r6VJo=
\r
32 Received: by 10.52.27.239 with SMTP id w15mr278036vdg.333.1315777667893;
\r
33 Sun, 11 Sep 2011 14:47:47 -0700 (PDT)
\r
34 Received: from localhost ([72.19.95.214])
\r
35 by mx.google.com with ESMTPS id by14sm9088735vdb.22.2011.09.11.14.47.44
\r
36 (version=TLSv1/SSLv3 cipher=OTHER);
\r
37 Sun, 11 Sep 2011 14:47:45 -0700 (PDT)
\r
38 From: Ben Gamari <bgamari.foss@gmail.com>
\r
39 To: Austin Clements <amdragon@MIT.EDU>,
\r
40 Sebastian Spaeth <Sebastian@sspaeth.de>, Carl Worth <cworth@cworth.org>
\r
41 Subject: Re: Memory management practices
\r
42 In-Reply-To: <20110909175328.GV5688@mit.edu>
\r
43 References: <8739h1pbaq.fsf@gmail.com> <87pqjprzu2.fsf@gmail.com>
\r
44 <20110829183010.GA2605@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f>
\r
45 <87liucyn7i.fsf@gmail.com> <87aaag3xaf.fsf@gmail.com>
\r
46 <CAH-f9WsfHUm_D-+wB89Lt9Wt=hjwDyywvJTK-0NwmHRg0TUsxQ@mail.gmail.com>
\r
47 <CAH-f9WveBfvmv2jOF+C81OeeQJt06g6U0q3J_idHrs60DLw7+g@mail.gmail.com>
\r
48 <87zkiff8in.fsf@SSpaeth.de> <20110908151557.GM5688@mit.edu>
\r
49 <8762l22hgk.fsf@SSpaeth.de> <20110909175328.GV5688@mit.edu>
\r
50 User-Agent: Notmuch/0.7-37-g5c3c7f6 (http://notmuchmail.org) Emacs/23.2.1
\r
51 (x86_64-pc-linux-gnu)
\r
52 Date: Sun, 11 Sep 2011 17:47:43 -0400
\r
53 Message-ID: <87d3f64ups.fsf@gmail.com>
\r
55 Content-Type: text/plain; charset=us-ascii
\r
56 Cc: Bertram Felgenhauer <bertram.felgenhauer@googlemail.com>,
\r
57 notmuch <notmuch@notmuchmail.org>, Bart Massey <bart@cs.pdx.edu>
\r
58 X-BeenThere: notmuch@notmuchmail.org
\r
59 X-Mailman-Version: 2.1.13
\r
61 List-Id: "Use and development of the notmuch mail system."
\r
62 <notmuch.notmuchmail.org>
\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
66 List-Post: <mailto:notmuch@notmuchmail.org>
\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
70 X-List-Received-Date: Sun, 11 Sep 2011 21:47:49 -0000
\r
72 Sorry I've been so quiet on this recently. I've been a little under the
\r
75 On Fri, 9 Sep 2011 13:53:28 -0400, Austin Clements <amdragon@MIT.EDU> wrote:
\r
76 > Ah, the *Python* objects don't care, but the underlying C objects do.
\r
77 > Suppose the Query were finalized first. Python calls Query.__del__,
\r
78 > which calls notmuch_query_destroy, which releases the underlying
\r
79 > talloc references to the C notmuch_messages_t objects, causing talloc
\r
80 > to free the notmuch_messages_t. Messages._msgs now points to freed
\r
81 > memory, so when Python then finalizes the Messages object,
\r
82 > Messages.__del__ will pass this dangling pointer to
\r
83 > notmuch_messages_destroy, which will crash.
\r
85 Exactly. This is exactly what I suspect is happening in my case.
\r
88 > Hence my suggestion that, rather than trying to emulate C-style memory
\r
89 > management in bindings, bindings should create an additional talloc
\r
90 > reference to the underlying objects and rather than calling
\r
91 > notmuch_*_destroy during finalization, they should simply unlink this
\r
92 > additional reference.
\r
94 Currently talloc's reference counting interface is hidden behind
\r
95 _destroy. While this might be a fairly intrusive change, perhaps notmuch
\r
96 wants to juse expose a pair of reference counting *_ref/unref functions
\r
97 instead of the *_destroy. Most users would simply need to change
\r
98 existing *_destroy()s to _unref()s. Furthermore, this would allow
\r
99 bindings authors to easily ensure non-broken GC behavior.
\r
101 Does this sound completely insane, somewhat insane, or reasonable?
\r