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 7F0C56DE0B22 for ; Fri, 20 Apr 2018 11:31:58 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[AWL=0.011, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] 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 yka5-IOEx0SE for ; Fri, 20 Apr 2018 11:31:57 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 857A36DE09BD for ; Fri, 20 Apr 2018 11:31:51 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1f9ap4-00071y-O1; Fri, 20 Apr 2018 14:31:50 -0400 Received: (nullmailer pid 14511 invoked by uid 1000); Fri, 20 Apr 2018 18:31:45 -0000 From: David Bremner To: notmuch@notmuchmail.org, David Bremner Subject: [PATCH 3/6] lib: break reference loop by choosing arbitrary top level msg Date: Fri, 20 Apr 2018 15:31:32 -0300 Message-Id: <20180420183135.14331-4-david@tethera.net> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180420183135.14331-1-david@tethera.net> References: <20180414014610.15438-6-david@tethera.net> <20180420183135.14331-1-david@tethera.net> 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, 20 Apr 2018 18:31:58 -0000 Other parts of notmuch (e.g. notmuch show) expect each thread to contain at least one top level message, and crash if this expectation is not met. --- lib/thread.cc | 8 +++++++- test/T050-new.sh | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/thread.cc b/lib/thread.cc index 3561b27f..dbac002f 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -397,7 +397,13 @@ _resolve_thread_relationships (notmuch_thread_t *thread) for (node = thread->message_list->head; node; node = node->next) { message = node->message; in_reply_to = _notmuch_message_get_in_reply_to (message); - if (in_reply_to && strlen (in_reply_to) && + /* + * if we reach the end of the list without finding a top-level + * message, that means the thread is a cycle (or set of + * cycles) and any message can be considered top-level + */ + if ((thread->toplevel_list->head || node->next) && + in_reply_to && strlen (in_reply_to) && g_hash_table_lookup_extended (thread->message_hash, in_reply_to, NULL, (void **) &parent)) diff --git a/test/T050-new.sh b/test/T050-new.sh index b9854978..f3bfe7b1 100755 --- a/test/T050-new.sh +++ b/test/T050-new.sh @@ -356,7 +356,6 @@ test_expect_equal_file EXPECTED OUTPUT add_email_corpus broken test_begin_subtest "reference loop does not crash" -test_subtest_known_broken test_expect_code 0 "notmuch show --format=json id:mid-loop-12@example.org id:mid-loop-21@example.org > OUTPUT" test_done -- 2.17.0