From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 0A6F8431FBD for ; Fri, 24 Jan 2014 13:12:58 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zCtSSfprx-Mi for ; Fri, 24 Jan 2014 13:12:50 -0800 (PST) Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com [74.125.83.51]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 79316431FB6 for ; Fri, 24 Jan 2014 13:12:50 -0800 (PST) Received: by mail-ee0-f51.google.com with SMTP id b57so1190496eek.24 for ; Fri, 24 Jan 2014 13:12:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=ozpPLqkpNp4OC3jDGoFEOHaPe9Oh5pL7fZrHTBeXCcc=; b=QcOuKdSj39tcLw5nKaHcSRxWLg3nzVxCG/m03vtRdJHE0bW86Ui8wE1ldEiTVsDBoA SUhJH6jqvcFHi2fYIHU2MLDhVsyrhe4KwihSifPcUjhdKXakEPez6TT7PcIGKKfaweSm aAtMfjBJTfGpoY0gbImcoSuF7J8YGpZrZJBRUgfLmNAdKRaeaNhJiBzx026S+naNnnbJ Q2y1gvIbmG+K2tPhgkatKsdMguXgGSfReV/6neYMscL7cpM3TB380rsW6h2uH6qOAiQm Uwz2Fv3G3MTb0HvLzHFVW1g8MU5vqWJQRf9F1VJG5gQ9XaAMnJyGcdjpIHt06A0lQXHf E1bA== X-Gm-Message-State: ALoCoQlp6HkyuCSr8GKaMJk/7S4+0aPRTT4RrFkDVQc4P7BwofHkmdySrKDWysRj1SRSUAT3jzzr X-Received: by 10.15.24.142 with SMTP id j14mr14833262eeu.52.1390597969085; Fri, 24 Jan 2014 13:12:49 -0800 (PST) Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. [88.195.111.91]) by mx.google.com with ESMTPSA id 8sm7923393eeq.15.2014.01.24.13.12.47 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 24 Jan 2014 13:12:48 -0800 (PST) From: Jani Nikula To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 3/3] notmuch-show: detect xapian exception in query In-Reply-To: <1390479841-17045-4-git-send-email-david@tethera.net> References: <1390479841-17045-1-git-send-email-david@tethera.net> <1390479841-17045-4-git-send-email-david@tethera.net> User-Agent: Notmuch/0.17+44~ge3b4cd9 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Fri, 24 Jan 2014 23:12:46 +0200 Message-ID: <87txctf5ip.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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, 24 Jan 2014 21:12:58 -0000 On Thu, 23 Jan 2014, David Bremner wrote: > We want to return an error status, not 0 or (worse) segfault. > --- > notmuch-show.c | 6 +++++- > test/T520-show.sh | 1 - > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/notmuch-show.c b/notmuch-show.c > index 528694b..b162738 100644 > --- a/notmuch-show.c > +++ b/notmuch-show.c > @@ -1015,9 +1015,13 @@ do_show (void *ctx, > notmuch_messages_t *messages; > notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS; > > + threads = notmuch_query_search_threads (query); > + if (! threads) > + return NOTMUCH_STATUS_XAPIAN_EXCEPTION; This should just return 1 or something. See how the function eventually returns res != NOTMUCH_STATUS_SUCCESS instead of notmuch_status_t. And threads == NULL is not guaranteed to mean an exception occurred anyway. Otherwise the patch LGTM, and is in line with the error handling in notmuch search, which does not segfault on similar queries. BR, Jani. > + > sp->begin_list (sp); > > - for (threads = notmuch_query_search_threads (query); > + for ( ; > notmuch_threads_valid (threads); > notmuch_threads_move_to_next (threads)) > { > diff --git a/test/T520-show.sh b/test/T520-show.sh > index bdd9d71..0657c99 100755 > --- a/test/T520-show.sh > +++ b/test/T520-show.sh > @@ -6,7 +6,6 @@ test_description='"notmuch show"' > add_email_corpus > > test_begin_subtest "exit code for show invalid query" > -test_subtest_known_broken > notmuch show foo.. > exit_code=$? > test_expect_equal 1 $exit_code > -- > 1.8.5.2 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch