From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gLH6IxQCBWLedwAAgWs5BA (envelope-from ) for ; Thu, 10 Feb 2022 13:16:20 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id aBZlIRQCBWIX2gAA9RJhRA (envelope-from ) for ; Thu, 10 Feb 2022 13:16:20 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 06FAC13CA2 for ; Thu, 10 Feb 2022 13:16:20 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 905375F718; Thu, 10 Feb 2022 12:16:17 +0000 (UTC) Received: from mailproxy05.manitu.net (mailproxy05.manitu.net [IPv6:2a00:1828:1000:1110::2]) by mail.notmuchmail.org (Postfix) with ESMTPS id 58E2C5F714 for ; Thu, 10 Feb 2022 12:16:14 +0000 (UTC) Received: from localhost (200116b8605b9100a390552ff161dcf3.dip.versatel-1u1.de [IPv6:2001:16b8:605b:9100:a390:552f:f161:dcf3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: michael@grubix.eu) by mailproxy05.manitu.net (Postfix) with ESMTPSA id 7D88D1B607F4; Thu, 10 Feb 2022 13:16:13 +0100 (CET) MIME-Version: 1.0 In-Reply-To: <164447257269.144855.18033927138350290920@sarek.home.aplund.id.au> References: <164447257269.144855.18033927138350290920@sarek.home.aplund.id.au> Subject: Re: Python binding SIGABRT/SIGSEGV To: Austin Lund , notmuch@notmuchmail.org From: Michael J Gruber Message-ID: <164449537318.6325.7517307804708659382.git@grubix.eu> Date: Thu, 10 Feb 2022 13:16:13 +0100 User-Agent: alot/0.10 Message-ID-Hash: EDEPNT2J2FGOWGZM3CNHRYZY6727LLR6 X-Message-ID-Hash: EDEPNT2J2FGOWGZM3CNHRYZY6727LLR6 X-MailFrom: michael@grubix.eu X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1644495380; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=NsRtfOECHt1UZO9pjTgcGNV0bQL+sQJLgHJGO02M5Lw=; b=S9Xq82kyVwHsT8bOV9BaZNAacV+1ZvSxvCIEOU3XpwfLMgnhZy/r86cyJbLN3jrURdhGeD kOgn6S4eer5uyO56w4cYtDmPgeJgv/ZyHCdgkYqcIl5ocb6fz0sUB6bz0jK2TDHt408hIj QSwydwgRXDFhMnzxYSJZWz8wXChYvkNLRNEuj9tM/Jf76th5i6pr/J1VXCpgJkanuuVcWp CKFcYXnqMsitlhITWVrUU8jjZJzP4OVjIh/Wgwx+czxQQ2K9HffJCyvelYNId6mDPU6+v1 ynHjqywL1VFswGZonfZgJGXiWHyTJxT6UUGbbaWr7lMZDmKeLf9IV2h7T6GQ/Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644495380; a=rsa-sha256; cv=none; b=W9dPz6hnMjS4ZqE42IfFTioAinG6F86HMG2my7NZGjXsmsGKcpUPwUU/62cITy7bCUk8dO 03vNQmK5trHMk9Aa2vqTgJUKsys1bFE+COnrYH2gFBcbx2+/w2JO7wGrs/n6eXgD9uhEqH /rnikpmW20dmSgrSGQ6zQcGCd/5wNvMRbLbqU8C0JxhlBLeH1eAiX/4KEcWI0/tgZeZzP7 brdoS0bXEQlWtJhQoLHbLkWUghiArOBo2poGvE9VhwB7uni+S9qk8qeHuq5n0oasEkCEIk 52hsQXD8zTKlLxRBLaLDleaq9R9tAHwOQ3Np7WuL7clysaBRtDKhOT4KGLD/pA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -2.83 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 06FAC13CA2 X-Spam-Score: -2.83 X-Migadu-Scanner: scn0.migadu.com X-TUID: 2SNuCQsstKWD Austin Lund venit, vidit, dixit 2022-02-10 06:56:12: > I'm clearly doing this python code wrong by not using the iterator correctly: > > > import notmuch2 > > > > d = notmuch2.Database() > > m = list(d.messages("since:today")) > > p = m[0].path > > print(p) > > But I seem to be getting a SIGABRT instead of a python stack trace. Is > this the expected behaviour? You didn't expect it :) And this can be confusing. d.messages() returns an iterator through Message objects whose lifetime depends on the iterator. In contrast, thread.get_messages() returns on iterator through OwnedMessage objects whose lifetime depends on the thread. As soon as the iterator is depleted, the returned objects are (possibly) gone. (Well, because it's return by reference in Python, and ...) If you're interested in m[0] only you can "cheat" by not depleting the iterator: mm = next(d.messages("since:today")) p = mm.path This never frees the object (I think). My attempts with notmuch2._message.OwnedMessage (and db as parent) failed. There must be a better way, possibly using a context manager or search. I guess usually people just use the iterator in a for loop and do something with the message inside the loop (while the iterator is not depleted), such as converting it into a proper email.Message object (i.e. instantiating a new object from it). Michael