--- /dev/null
+Return-Path: <david@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 66F61431FBD\r
+ for <notmuch@notmuchmail.org>; Wed, 22 Jan 2014 04:41:10 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id l4sylLm+w-Tr for <notmuch@notmuchmail.org>;\r
+ Wed, 22 Jan 2014 04:41:06 -0800 (PST)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
+ (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 5413A431FAF\r
+ for <notmuch@notmuchmail.org>; Wed, 22 Jan 2014 04:41:06 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <david@tethera.net>)\r
+ id 1W5x76-0000rb-KS; Wed, 22 Jan 2014 08:41:00 -0400\r
+Received: (nullmailer pid 3724 invoked by uid 1000); Wed, 22 Jan 2014\r
+ 12:40:56 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: Sanjoy Mahajan <sanjoy@olin.edu>, notmuch@notmuchmail.org\r
+Subject: Re: segfault if notmuch-show query has spurious .. (w/ v0.17)\r
+In-Reply-To: <871u00oimv.fsf@approx.mit.edu>\r
+References: <871u00oimv.fsf@approx.mit.edu>\r
+User-Agent: Notmuch/0.17+35~g3b36898 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Wed, 22 Jan 2014 08:40:56 -0400\r
+Message-ID: <8738kgrxyf.fsf@zancas.localnet>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 22 Jan 2014 12:41:10 -0000\r
+\r
+Sanjoy Mahajan <sanjoy@olin.edu> writes:\r
+\r
+> Probably because I kept using notmuch-emacs .elc code from 0.16 after\r
+> notmuch got upgraded to 0.17 (I rarely restart emacs), my Emacs\r
+> interface to notmuch started generating queries that caused Xapian\r
+> exceptions and segfaults. Here's one:\r
+>\r
+> $ notmuch show '( FW: Student Employment Orie.. )'\r
+> A Xapian exception occurred performing query: Unknown range operation\r
+> Query string was: ( FW: Student Employment Orie.. )\r
+> Segmentation fault\r
+>\r
+> Restarting Emacs stopped those queries, so I don't think that's an\r
+> issue. However, notmuch itself probably should not segfault, even if\r
+> Xapian gets confused by the .. in the query (making it look like a date\r
+> range).\r
+>\r
+\r
+Looking at the example code in lib/notmuch.h (which, surprise, we use in\r
+notmuch-show), we see\r
+\r
+ for (threads = notmuch_query_search_threads (query);\r
+ notmuch_threads_valid (threads);\r
+ notmuch_threads_move_to_next (threads))\r
+ {\r
+ thread = notmuch_threads_get (threads);\r
+ ....\r
+ notmuch_thread_destroy (thread);\r
+ }\r
+\r
+notmuch_query_search_theads documents that it might return NULL, but\r
+notmuch_threads_valid does not handle NULL input. It seems to me that\r
+notmuch_threads_valid should just return FALSE on NULL input. \r
+\r
+d\r