unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH 3/3] notmuch-show: detect xapian exception in query
Date: Fri, 24 Jan 2014 23:12:46 +0200	[thread overview]
Message-ID: <87txctf5ip.fsf@nikula.org> (raw)
In-Reply-To: <1390479841-17045-4-git-send-email-david@tethera.net>

On Thu, 23 Jan 2014, David Bremner <david@tethera.net> 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

  reply	other threads:[~2014-01-24 21:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-22  2:27 segfault if notmuch-show query has spurious .. (w/ v0.17) Sanjoy Mahajan
2014-01-22 12:40 ` David Bremner
2014-01-22 16:42   ` [PATCH] lib: make notmuch_threads_valid return FALSE when passed NULL David Bremner
2014-01-22 17:30     ` Tomi Ollila
2014-01-23 12:23       ` Round 2: fix for notmuch show segfault David Bremner
2014-01-23 12:23         ` [PATCH 1/3] test: add known broken test exit code of notmuch show David Bremner
2014-01-23 12:24         ` [PATCH 2/3] lib: make notmuch_threads_valid return FALSE when passed NULL David Bremner
2014-01-24 21:06           ` Jani Nikula
2014-01-23 12:24         ` [PATCH 3/3] notmuch-show: detect xapian exception in query David Bremner
2014-01-24 21:12           ` Jani Nikula [this message]
2014-01-25  0:41             ` David Bremner
2014-01-23 17:50         ` Round 2: fix for notmuch show segfault Mark Walters
2014-01-24 18:43           ` Tomi Ollila
2014-01-25  1:01 ` segfault if notmuch-show query has spurious .. (w/ v0.17) David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87txctf5ip.fsf@nikula.org \
    --to=jani@nikula.org \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).