From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id PQa3ApdBzWC3OAEAgWs5BA (envelope-from ) for ; Sat, 19 Jun 2021 03:00:07 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id mEGIOZZBzWA2QAAAB5/wlQ (envelope-from ) for ; Sat, 19 Jun 2021 01:00:06 +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) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 83C711818F for ; Sat, 19 Jun 2021 03:00:06 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 5EF672B1F5; Fri, 18 Jun 2021 20:59:58 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 284D727E2B for ; Fri, 18 Jun 2021 20:59:53 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id AB8A55FD25; Fri, 18 Jun 2021 20:59:52 -0400 (EDT) Received: (nullmailer pid 2267225 invoked by uid 1000); Sat, 19 Jun 2021 00:59:50 -0000 From: David Bremner To: notmuch@notmuchmail.org Cc: David Bremner Subject: [PATCH 1/2] lib: write talloc report in notmuch_database_destroy Date: Fri, 18 Jun 2021 21:59:43 -0300 Message-Id: <20210619005944.2267177-1-david@tethera.net> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Message-ID-Hash: CBZBCEZUGVWRN42B6INP7MQZXXP2IVLA X-Message-ID-Hash: CBZBCEZUGVWRN42B6INP7MQZXXP2IVLA 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-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624064406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=StZVG+sLL+O3TD/vBXUonjS6J0XVufh8LQ66Xez7lCY=; b=A6lyDaXVPR+Dn3e2tmxpl3dJzUuOLQAtBZ4CAKrc9pbEOrp6o0rFrOdV25UWh+j+caGdG/ Amsyugyq3X/2UlPlx6i1TKDk9RTvx2+AA/kGzJVOW9qzP535QwnUV0ZEo3sZ+KPQQkDBQ1 0rKWzMGi9939N8FAXAMWICXesMKrcHN25+AdsiJ9E+R4E0wlmfKv/oTTlT+ZQW40WjUBE4 MyaSQT4mvJCMrOqhyZO1QT3VRnDKa64lq4xgmAI+ADdF7qhRp3UFZw4JVwDcJH2APwfpsQ CPbdnANfhUZ+/DbQmUwMXBNhHYcR3zFkMidKP+xf5ixDXPKyI14cA585ImpGNw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624064406; a=rsa-sha256; cv=none; b=Na0dCiAZlion6HQsmz+xHHmaWvsETKyMqAkAJvsPyjZkW754zCFYUOvQxMJ2umDnsLsP6V ZwyJY+DboK9m7GvtEwiaGL2DDLcfptk2GCZvjModdg1KoXWMemECn9bCuwMMhAVUeKTFjV P0h9aIO0FxP6hnHoh7N+xLf62qnIB/s1yZxAkTbE4WWwspniIIYqDEFN/eDimlLPrRUkYU s3k9AVJsrrYCSllz3eDJyjVK9dLLHbRImaupqvhiq1u3BPA+6e7t8u0Li2QA2qoGs5KATZ MzdMpWjs2gkxMpcqpyYv5hB3ZsBcDWDZD6KvN5qV/e513G3s3A1Qa28L3XkVVg== ARC-Authentication-Results: i=1; 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-Migadu-Spam-Score: -1.06 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-Migadu-Queue-Id: 83C711818F X-Spam-Score: -1.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: VHUCeNzVXpTl Since most memory allocation is (ultimately) in the talloc context defined by a notmuch_database_t pointer, this gives a more complete view of memory still allocated at program shutdown. We also change the talloc report in notmuch.c to mode "a" to avoid clobbering the newly reported log. --- lib/database.cc | 9 +++++++++ notmuch.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/database.cc b/lib/database.cc index 96458f6f..0052cb65 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -733,6 +733,15 @@ notmuch_status_t notmuch_database_destroy (notmuch_database_t *notmuch) { notmuch_status_t status; + const char* talloc_report; + + talloc_report = getenv ("NOTMUCH_TALLOC_REPORT"); + if (talloc_report && strcmp (talloc_report, "") != 0) { + FILE *report = fopen (talloc_report, "a"); + if (report) { + talloc_report_full (notmuch, report); + } + } status = notmuch_database_close (notmuch); diff --git a/notmuch.c b/notmuch.c index d0a94fc2..1404b70c 100644 --- a/notmuch.c +++ b/notmuch.c @@ -589,7 +589,7 @@ main (int argc, char *argv[]) * talloc_enable_null_tracking */ - FILE *report = fopen (talloc_report, "w"); + FILE *report = fopen (talloc_report, "a"); if (report) { talloc_report_full (NULL, report); } else { -- 2.30.2