From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yJBsHMEDKl/zVwAA0tVLHw (envelope-from ) for ; Wed, 05 Aug 2020 00:56:33 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id MAtSGMEDKl9mYgAA1q6Kng (envelope-from ) for ; Wed, 05 Aug 2020 00:56:33 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 14B6894013C for ; Wed, 5 Aug 2020 00:56:31 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 002FC29A8B; Tue, 4 Aug 2020 20:56:22 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id EAFFA1FA17 for ; Tue, 4 Aug 2020 20:56:19 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id B6E925FA66; Tue, 4 Aug 2020 20:56:16 -0400 (EDT) Received: (nullmailer pid 868702 invoked by uid 1000); Wed, 05 Aug 2020 00:56:03 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH] lib/config: delay setting talloc destructor Date: Tue, 4 Aug 2020 21:56:01 -0300 Message-Id: <20200805005601.868637-1-david@tethera.net> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Message-ID-Hash: BEUE26LUS2MNOHPSYGJRHSYHBROPLNI2 X-Message-ID-Hash: BEUE26LUS2MNOHPSYGJRHSYHBROPLNI2 X-MailFrom: bremner@tethera.net 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; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 0.03 X-TUID: bg/l1ZJXspPO If Xapian has thrown an exception, it is not safe to invoke the destuctor when freeing the list struct. --- this is a latent exception handling bug I missed before. It showed up when updating some config related code, but I guess we were just lucky(?) before. The bug manifests as one of the tests in T590-libconfig failing. lib/config.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/config.cc b/lib/config.cc index f5def3aa..ca7ac2a8 100644 --- a/lib/config.cc +++ b/lib/config.cc @@ -113,7 +113,6 @@ notmuch_database_get_config_list (notmuch_database_t *notmuch, goto DONE; } - talloc_set_destructor (list, _notmuch_config_list_destroy); list->notmuch = notmuch; list->current_key = NULL; list->current_val = NULL; @@ -133,8 +132,15 @@ notmuch_database_get_config_list (notmuch_database_t *notmuch, *out = list; DONE: - if (status && list) - talloc_free (list); + if (status) { + if (list) { + talloc_free (list); + if (status != NOTMUCH_STATUS_XAPIAN_EXCEPTION) + _notmuch_config_list_destroy (list); + } + } else { + talloc_set_destructor (list, _notmuch_config_list_destroy); + } return status; } -- 2.27.0