Re: [PATCH 3/3] notmuch-show: detect xapian exception in query
[notmuch-archives.git] / 2d / b3323a1b49ba6c4c2ae9029a2cb3462206c988
1 Return-Path: <jani@nikula.org>\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 0A6F8431FBD\r
6         for <notmuch@notmuchmail.org>; Fri, 24 Jan 2014 13:12:58 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id zCtSSfprx-Mi for <notmuch@notmuchmail.org>;\r
16         Fri, 24 Jan 2014 13:12:50 -0800 (PST)\r
17 Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com\r
18  [74.125.83.51])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  79316431FB6    for <notmuch@notmuchmail.org>; Fri, 24 Jan 2014 13:12:50 -0800\r
21  (PST)\r
22 Received: by mail-ee0-f51.google.com with SMTP id b57so1190496eek.24\r
23         for <notmuch@notmuchmail.org>; Fri, 24 Jan 2014 13:12:49 -0800 (PST)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=1e100.net; s=20130820;\r
26         h=x-gm-message-state:from:to:subject:in-reply-to:references\r
27         :user-agent:date:message-id:mime-version:content-type;\r
28         bh=ozpPLqkpNp4OC3jDGoFEOHaPe9Oh5pL7fZrHTBeXCcc=;\r
29         b=QcOuKdSj39tcLw5nKaHcSRxWLg3nzVxCG/m03vtRdJHE0bW86Ui8wE1ldEiTVsDBoA\r
30         SUhJH6jqvcFHi2fYIHU2MLDhVsyrhe4KwihSifPcUjhdKXakEPez6TT7PcIGKKfaweSm\r
31         aAtMfjBJTfGpoY0gbImcoSuF7J8YGpZrZJBRUgfLmNAdKRaeaNhJiBzx026S+naNnnbJ\r
32         Q2y1gvIbmG+K2tPhgkatKsdMguXgGSfReV/6neYMscL7cpM3TB380rsW6h2uH6qOAiQm\r
33         Uwz2Fv3G3MTb0HvLzHFVW1g8MU5vqWJQRf9F1VJG5gQ9XaAMnJyGcdjpIHt06A0lQXHf\r
34         E1bA==\r
35 X-Gm-Message-State:\r
36  ALoCoQlp6HkyuCSr8GKaMJk/7S4+0aPRTT4RrFkDVQc4P7BwofHkmdySrKDWysRj1SRSUAT3jzzr\r
37 X-Received: by 10.15.24.142 with SMTP id j14mr14833262eeu.52.1390597969085;\r
38         Fri, 24 Jan 2014 13:12:49 -0800 (PST)\r
39 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
40         [88.195.111.91])\r
41         by mx.google.com with ESMTPSA id 8sm7923393eeq.15.2014.01.24.13.12.47\r
42         for <multiple recipients>\r
43         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
44         Fri, 24 Jan 2014 13:12:48 -0800 (PST)\r
45 From: Jani Nikula <jani@nikula.org>\r
46 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
47 Subject: Re: [PATCH 3/3] notmuch-show: detect xapian exception in query\r
48 In-Reply-To: <1390479841-17045-4-git-send-email-david@tethera.net>\r
49 References: <m2r47zrkkc.fsf@guru.guru-group.fi>\r
50         <1390479841-17045-1-git-send-email-david@tethera.net>\r
51         <1390479841-17045-4-git-send-email-david@tethera.net>\r
52 User-Agent: Notmuch/0.17+44~ge3b4cd9 (http://notmuchmail.org) Emacs/24.3.1\r
53         (x86_64-pc-linux-gnu)\r
54 Date: Fri, 24 Jan 2014 23:12:46 +0200\r
55 Message-ID: <87txctf5ip.fsf@nikula.org>\r
56 MIME-Version: 1.0\r
57 Content-Type: text/plain\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\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: Fri, 24 Jan 2014 21:12:58 -0000\r
71 \r
72 On Thu, 23 Jan 2014, David Bremner <david@tethera.net> wrote:\r
73 > We want to return an error status, not 0 or (worse) segfault.\r
74 > ---\r
75 >  notmuch-show.c    | 6 +++++-\r
76 >  test/T520-show.sh | 1 -\r
77 >  2 files changed, 5 insertions(+), 2 deletions(-)\r
78 >\r
79 > diff --git a/notmuch-show.c b/notmuch-show.c\r
80 > index 528694b..b162738 100644\r
81 > --- a/notmuch-show.c\r
82 > +++ b/notmuch-show.c\r
83 > @@ -1015,9 +1015,13 @@ do_show (void *ctx,\r
84 >      notmuch_messages_t *messages;\r
85 >      notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;\r
86 >  \r
87 > +    threads = notmuch_query_search_threads (query);\r
88 > +    if (! threads)\r
89 > +     return NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
90 \r
91 This should just return 1 or something. See how the function eventually\r
92 returns res != NOTMUCH_STATUS_SUCCESS instead of notmuch_status_t. And\r
93 threads == NULL is not guaranteed to mean an exception occurred anyway.\r
94 \r
95 Otherwise the patch LGTM, and is in line with the error handling in\r
96 notmuch search, which does not segfault on similar queries.\r
97 \r
98 BR,\r
99 Jani.\r
100 \r
101 \r
102 > +\r
103 >      sp->begin_list (sp);\r
104 >  \r
105 > -    for (threads = notmuch_query_search_threads (query);\r
106 > +    for ( ;\r
107 >        notmuch_threads_valid (threads);\r
108 >        notmuch_threads_move_to_next (threads))\r
109 >      {\r
110 > diff --git a/test/T520-show.sh b/test/T520-show.sh\r
111 > index bdd9d71..0657c99 100755\r
112 > --- a/test/T520-show.sh\r
113 > +++ b/test/T520-show.sh\r
114 > @@ -6,7 +6,6 @@ test_description='"notmuch show"'\r
115 >  add_email_corpus\r
116 >  \r
117 >  test_begin_subtest "exit code for show invalid query"\r
118 > -test_subtest_known_broken\r
119 >  notmuch show foo..\r
120 >  exit_code=$?\r
121 >  test_expect_equal 1 $exit_code\r
122 > -- \r
123 > 1.8.5.2\r
124 >\r
125 > _______________________________________________\r
126 > notmuch mailing list\r
127 > notmuch@notmuchmail.org\r
128 > http://notmuchmail.org/mailman/listinfo/notmuch\r