--- /dev/null
+Return-Path: <mh@glandium.org>\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 506BC431FBC\r
+ for <notmuch@notmuchmail.org>; Fri, 20 Nov 2009 05:27:04 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\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 5GtjFInyAT36 for <notmuch@notmuchmail.org>;\r
+ Fri, 20 Nov 2009 05:27:04 -0800 (PST)\r
+Received: from mout.perfora.net (mout.perfora.net [74.208.4.195])\r
+ by olra.theworths.org (Postfix) with ESMTP id 3426C431FAE\r
+ for <notmuch@notmuchmail.org>; Fri, 20 Nov 2009 05:27:04 -0800 (PST)\r
+Received: from vuizook.err.no (vuizook.err.no [85.19.221.46])\r
+ by mx.perfora.net (node=mxus1) with ESMTP (Nemesis)\r
+ id 0MGjw9-1NOxuB44DR-00DUaZ for notmuch@notmuchmail.org;\r
+ Fri, 20 Nov 2009 08:27:03 -0500\r
+Received: from cha92-13-88-165-248-19.fbx.proxad.net ([88.165.248.19]\r
+ helo=jigen)\r
+ by vuizook.err.no with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)\r
+ (Exim 4.69) (envelope-from <mh@glandium.org>) id 1NBTVq-0005pr-Tf\r
+ for notmuch@notmuchmail.org; Fri, 20 Nov 2009 14:27:01 +0100\r
+Received: from mh by jigen with local (Exim 4.69) (envelope-from <mh@jigen>)\r
+ id 1NBTVJ-00050w-DR\r
+ for notmuch@notmuchmail.org; Fri, 20 Nov 2009 14:26:25 +0100\r
+Date: Fri, 20 Nov 2009 14:26:25 +0100\r
+From: Mike Hommey <mh+notmuch@glandium.org>\r
+To: notmuch@notmuchmail.org\r
+Message-ID: <20091120132625.GA19246@glandium.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+X-GPG-Fingerprint: A479 A824 265C B2A5 FC54 8D1E DE4B DA2C 54FD 2A58\r
+User-Agent: Mutt/1.5.20 (2009-06-14)\r
+Subject: [notmuch] Segfault with weird Message-ID\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.12\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: Fri, 20 Nov 2009 13:27:04 -0000\r
+\r
+Hi,\r
+\r
+I got a segfault when importing my maildir. It happened because of an\r
+old weird email, where the message-id is the following:\r
+Message-ID: <000022b17a1f$00004fbe$00000550@myrop (ew6.southwind.net [216.53.98.70]) by onyx.southwind.net from homepage.com (114.230.197.216) by newmail.spectraweb.ch from default (m202.2-25.warwick.net [\r
+218.242.202.80]) by host.warwick.net (8.10.0.Beta10/8.10.0.Beta10) with SMTP id e9GKEKk19201>\r
+\r
+I have absolutely no idea how it got this value, but the mail being\r
+an archived 8 years old spam, I'm not exactly sure if anyone would \r
+still expect such message id to occur.\r
+\r
+Anyways, the stack dump is the following:\r
+#0 0x00007ffff6d1e598 in Xapian::Document::add_term(std::string const&, unsigned int) () from /usr/lib/libxapian.so.15\r
+#1 0x000000000040f5ff in _notmuch_message_add_term (message=0x0, prefix_name=0x41ad7f "tag", value=0x4191b0 "inbox") at lib/message.cc:587\r
+#2 0x000000000040f827 in notmuch_message_add_tag (message=0x0, tag=0x4191b0 "inbox") at lib/message.cc:668\r
+#3 0x0000000000407bc8 in tag_inbox_and_unread (message=0x0) at notmuch-new.c:44\r
+#4 0x0000000000407f63 in add_files_recursive (notmuch=0x62cc20, path=0x832e90 "/home/mh/Maildir/saved-messages/cur", st=0x7fffffffe000, state=0x7fffffffe240) at notmuch-new.c:185\r
+#5 0x0000000000408036 in add_files_recursive (notmuch=0x62cc20, path=0x832de0 "/home/mh/Maildir/saved-messages", st=0x7fffffffe000, state=0x7fffffffe240) at notmuch-new.c:223\r
+#6 0x0000000000408036 in add_files_recursive (notmuch=0x62cc20, path=0x62c920 "/home/mh/Maildir", st=0x7fffffffe000, state=0x7fffffffe240) at notmuch-new.c:223\r
+#7 0x0000000000408245 in add_files (notmuch=0x62cc20, path=0x62c920 "/home/mh/Maildir", state=0x7fffffffe240) at notmuch-new.c:287\r
+#8 0x0000000000408704 in notmuch_new_command (ctx=0x61f140, argc=0, argv=0x7fffffffe3e8) at notmuch-new.c:431\r
+#9 0x0000000000406ea8 in main (argc=2, argv=0x7fffffffe3d8) at notmuch.c:400\r
+\r
+And the most likely problem is that message is NULL.\r
+\r
+Now, looking at the code, there seems to me there actually 3 problems:\r
+- _notmuch_message_create_for_message_id can return NULL, and while\r
+ there is a test for it in notmuch_database_add_message, the function\r
+ still returns a success code\r
+- things are still going on even when message is NULL in\r
+ add_files_recursive\r
+- for some reason, xapian doesn't want to add the document corresponding\r
+ to this old spam message: notmuch->xapian_db->add_document throws an\r
+ exception.\r
+\r
+I can provide the spam if necessary, or can continue debugging the issue\r
+with some guidance.\r
+\r
+Cheers,\r
+\r
+Mike\r