Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / d5 / a235a6415f39953a9c4e808b55a7c0752a1fb0
1 Return-Path: <david@tethera.net>\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 arlo.cworth.org (Postfix) with ESMTP id 1AE446DE0222\r
6  for <notmuch@notmuchmail.org>; Thu,  9 Jun 2016 11:07:10 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.011\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.011 tagged_above=-999 required=5\r
12  tests=[AWL=-0.000, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01]\r
13  autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id Eob_sFdZ8LxG for <notmuch@notmuchmail.org>;\r
17  Thu,  9 Jun 2016 11:07:02 -0700 (PDT)\r
18 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
19  by arlo.cworth.org (Postfix) with ESMTPS id 6E07A6DE01BE\r
20  for <notmuch@notmuchmail.org>; Thu,  9 Jun 2016 11:07:02 -0700 (PDT)\r
21 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
22  (envelope-from <david@tethera.net>)\r
23  id 1bB4Lw-0005be-GO; Thu, 09 Jun 2016 14:06:48 -0400\r
24 Received: (nullmailer pid 6896 invoked by uid 1000);\r
25  Thu, 09 Jun 2016 18:06:58 -0000\r
26 From: David Bremner <david@tethera.net>\r
27 To: notmuch@notmuchmail.org\r
28 Subject: [Lars Luthman] Bug#826843: Calls to notmuch_database_add_message()\r
29  after notmuch_database_close() crash\r
30 User-Agent: Notmuch/0.22+28~gb9bf3f4 (http://notmuchmail.org) Emacs/24.5.1\r
31  (x86_64-pc-linux-gnu)\r
32 Date: Thu, 09 Jun 2016 15:06:58 -0300\r
33 Message-ID: <87porqxmm5.fsf@tesseract.cs.unb.ca>\r
34 MIME-Version: 1.0\r
35 Content-Type: message/rfc822\r
36 Content-Disposition: inline\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.20\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41  <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
43  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
48  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Thu, 09 Jun 2016 18:07:10 -0000\r
50 \r
51 Return-path: <notmuch-bounces@notmuchmail.org>\r
52 Envelope-to: david@tethera.net\r
53 Delivery-date: Thu, 09 Jun 2016 12:51:04 -0400\r
54 Received: from arlo.cworth.org ([50.126.95.6])\r
55         by fethera.tethera.net with esmtp (Exim 4.84)\r
56         (envelope-from <notmuch-bounces@notmuchmail.org>)\r
57         id 1bB3Ae-0004dq-L2\r
58         for david@tethera.net; Thu, 09 Jun 2016 12:51:04 -0400\r
59 Received: from localhost (localhost [127.0.0.1])\r
60         by arlo.cworth.org (Postfix) with ESMTP id 3A8906DE0314;\r
61         Thu,  9 Jun 2016 09:51:10 -0700 (PDT)\r
62 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
63 Received: from arlo.cworth.org ([127.0.0.1])\r
64         by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
65         with ESMTP id JlCNsTTh5kz0; Thu,  9 Jun 2016 09:51:02 -0700 (PDT)\r
66 Received: from arlo.cworth.org (localhost [IPv6:::1])\r
67         by arlo.cworth.org (Postfix) with ESMTP id 9F0766DE01C2;\r
68         Thu,  9 Jun 2016 09:50:54 -0700 (PDT)\r
69 X-Original-To: notmuch@notmuchmail.org\r
70 Delivered-To: notmuch@notmuchmail.org\r
71 Received: from localhost (localhost [127.0.0.1])\r
72  by arlo.cworth.org (Postfix) with ESMTP id 1FD286DE01C2\r
73  for <notmuch@notmuchmail.org>; Thu,  9 Jun 2016 08:44:36 -0700 (PDT)\r
74 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
75 Received: from arlo.cworth.org ([127.0.0.1])\r
76  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
77  with ESMTP id 8_30yotZM4k9 for <notmuch@notmuchmail.org>;\r
78  Thu,  9 Jun 2016 08:44:27 -0700 (PDT)\r
79 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
80  by arlo.cworth.org (Postfix) with ESMTPS id A6EEC6DE01BE\r
81  for <notmuch@notmuchmail.org>; Thu,  9 Jun 2016 08:44:27 -0700 (PDT)\r
82 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
83  (envelope-from <bounces+20160609-bremner=debian.org@tracker.debian.org>)\r
84  id 1bB27w-0003ly-4r\r
85  for notmuch@notmuchmail.org; Thu, 09 Jun 2016 11:44:12 -0400\r
86 Received: (nullmailer pid 558 invoked by uid 1000);\r
87  Thu, 09 Jun 2016 15:44:21 -0000\r
88 Resent-To: notmuch@notmuchmail.org\r
89 Resent-From: David Bremner <david@tethera.net>\r
90 Resent-Date: Thu, 09 Jun 2016 12:44:21 -0300\r
91 Resent-Message-ID: <87wplyxt7u.fsf@tesseract.cs.unb.ca>\r
92 Received: from mailly.debian.org ([2001:41b8:202:deb:6564:a62:52c3:4b72])\r
93  by fethera.tethera.net with esmtp (Exim 4.84)\r
94  (envelope-from <bounces+20160609-bremner=debian.org@tracker.debian.org>)\r
95  id 1bAxjp-0008T2-FK\r
96  for david@tethera.net; Thu, 09 Jun 2016 07:03:01 -0400\r
97 Received: from ticharich.debian.org ([2001:41c8:1000:21::21:23])\r
98  from C=NA, ST=NA, L=Ankh Morpork, O=Debian SMTP, OU=Debian SMTP CA,\r
99  CN=ticharich.debian.org, EMAIL=hostmaster@ticharich.debian.org (verified)\r
100  by mailly.debian.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\r
101  (Exim 4.84_2)\r
102  (envelope-from <bounces+20160609-bremner=debian.org@tracker.debian.org>)\r
103  id 1bAxk0-0004GV-Nd\r
104  for david@tethera.net; Thu, 09 Jun 2016 11:03:12 +0000\r
105 Received: from localhost ([::1] helo=ticharich.debian.org)\r
106  by ticharich.debian.org with esmtp (Exim 4.84_2)\r
107  (envelope-from <bounces+20160609-bremner=debian.org@tracker.debian.org>)\r
108  id 1bAxk0-00069c-DW\r
109  for david@tethera.net; Thu, 09 Jun 2016 11:03:12 +0000\r
110 Received: from muffat.debian.org ([2607:f8f0:610:4000:6564:a62:ce0c:1392])\r
111  from C=NA, ST=NA, L=Ankh Morpork, O=Debian SMTP, OU=Debian SMTP CA,\r
112  CN=muffat.debian.org, EMAIL=hostmaster@muffat.debian.org (verified)\r
113  by ticharich.debian.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\r
114  (Exim 4.84_2) (envelope-from <debbugs@buxtehude.debian.org>)\r
115  id 1bAxk0-00069V-4O\r
116  for dispatch+notmuch@tracker.debian.org; Thu, 09 Jun 2016 11:03:12 +0000\r
117 Received: from quantz.debian.org ([2001:41c8:1000:21::21:28])\r
118  from C=NA, ST=NA, L=Ankh Morpork, O=Debian SMTP, OU=Debian SMTP CA,\r
119  CN=quantz.debian.org, EMAIL=hostmaster@quantz.debian.org (verified)\r
120  by muffat.debian.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\r
121  (Exim 4.84_2) (envelope-from <debbugs@buxtehude.debian.org>)\r
122  id 1bAxjx-0005AY-PW\r
123  for dispatch+notmuch@tracker.debian.org; Thu, 09 Jun 2016 11:03:10 +0000\r
124 Received: from qa by quantz.debian.org with local (Exim 4.84_2)\r
125  (envelope-from <debbugs@buxtehude.debian.org>) id 1bAxjw-0006ua-BG\r
126  for dispatch+notmuch@tracker.debian.org; Thu, 09 Jun 2016 11:03:08 +0000\r
127 Received: from buxtehude.debian.org ([2607:f8f0:610:4000:2015:12:0:147])\r
128  from C=NA, ST=NA, L=Ankh Morpork, O=Debian SMTP, OU=Debian SMTP CA,\r
129  CN=buxtehude.debian.org, EMAIL=hostmaster@buxtehude.debian.org (verified)\r
130  by quantz.debian.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\r
131  (Exim 4.84_2) (envelope-from <debbugs@buxtehude.debian.org>)\r
132  id 1bAxjw-0006tk-4N\r
133  for notmuch@packages.qa.debian.org; Thu, 09 Jun 2016 11:03:08 +0000\r
134 Received: from debbugs by buxtehude.debian.org with local (Exim 4.84_2)\r
135  (envelope-from <debbugs@buxtehude.debian.org>)\r
136  id 1bAxjt-0005Bk-Ec; Thu, 09 Jun 2016 11:03:05 +0000\r
137 X-Loop: owner@bugs.debian.org\r
138 Subject: Bug#826843: Calls to notmuch_database_add_message() after\r
139  notmuch_database_close() crash\r
140 Also-Resent-From: Lars Luthman <deb-bugs@larsluthman.net>\r
141 Also-Resent-To: debian-bugs-dist@lists.debian.org\r
142 Also-Resent-CC: Carl Worth <cworth@debian.org>\r
143 X-Loop: owner@bugs.debian.org\r
144 Also-Resent-Date: Thu, 09 Jun 2016 11:03:01 +0000\r
145 Also-Resent-Message-ID: <handler.826843.B.146547014919804@bugs.debian.org>\r
146 X-Debian-PR-Message: report 826843\r
147 X-Debian-PR-Package: libnotmuch-dev\r
148 X-Debian-PR-Keywords: \r
149 X-Debian-PR-Source: notmuch\r
150 Received: via spool by submit@bugs.debian.org id=B.146547014919804\r
151  (code B); Thu, 09 Jun 2016 11:03:01 +0000\r
152 Received: (at submit) by bugs.debian.org; 9 Jun 2016 11:02:29 +0000\r
153 X-Spam-Bayes: score:0.0000 Tokens: new, 47; hammy, 150; neutral, 161; spammy,\r
154  0. spammytokens: hammytokens:0.000-+--systemd, 0.000-+--deb8u1, \r
155  0.000-+--H*UA:3.12.9-1, 0.000-+--H*x:3.12.9-1, 0.000-+--en_GButf8\r
156 Received: from v-smtpgw2.han.skanova.net ([81.236.60.205])\r
157  by buxtehude.debian.org with esmtp (Exim 4.84_2)\r
158  (envelope-from <deb-bugs@larsluthman.net>) id 1bAxjJ-00058n-Da\r
159  for submit@bugs.debian.org; Thu, 09 Jun 2016 11:02:29 +0000\r
160 Received: from miskatonic.local ([78.69.244.232]) by cmsmtp with SMTP\r
161  id Axj9bO3cdctqUAxjAb5kXm; Thu, 09 Jun 2016 13:02:21 +0200\r
162 Message-ID: <1465470142.3501.10.camel@larsluthman.net>\r
163 From: Lars Luthman <deb-bugs@larsluthman.net>\r
164 To: submit@bugs.debian.org\r
165 Date: Thu, 09 Jun 2016 13:02:22 +0200\r
166 X-Mailer: Evolution 3.12.9-1+b1 \r
167 X-CMAE-Envelope: MS4wfMMdDsIM1l3Qa1f8AMdqkBLsZulSFkVnPILa/7bnKy7vEm4kePEgzC6NTWfUzgizPIZAc6sUB2evyOmtpQUgDjqXQ6LEQxTtw+vIUvUyHA7aLhnK00Hl\r
168  FQksKsJl/A76jQ8iymRFjr2C22qm20As/LrAUsbskpt9lKP8xDC8VLW511/i88tLX5zSWk/3fOrzaA==\r
169 X-Loop: dispatch@tracker.debian.org\r
170 X-Distro-Tracker-Package: notmuch\r
171 X-Distro-Tracker-Keyword: bts\r
172 X-Debian-Package: notmuch\r
173 X-Debian: tracker.debian.org\r
174 X-PTS-Package: notmuch\r
175 X-PTS-Keyword: bts\r
176 Precedence: list\r
177 X-Mailman-Approved-At: Thu, 09 Jun 2016 09:50:52 -0700\r
178 X-BeenThere: notmuch@notmuchmail.org\r
179 X-Mailman-Version: 2.1.20\r
180 List-Id: "Use and development of the notmuch mail system."\r
181  <notmuch.notmuchmail.org>\r
182 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
183  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
184 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
185 List-Post: <mailto:notmuch@notmuchmail.org>\r
186 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
187 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
188  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
189 Reply-To: Lars Luthman <deb-bugs@larsluthman.net>, 826843@bugs.debian.org\r
190 Errors-To: notmuch-bounces@notmuchmail.org\r
191 Sender: "notmuch" <notmuch-bounces@notmuchmail.org>\r
192 MIME-Version: 1.0\r
193 Content-Type: multipart/mixed; boundary="==-=-="\r
194 \r
195 --==-=-=\r
196 Content-Type: text/plain; charset=utf-8\r
197 Content-Disposition: inline\r
198 \r
199 Package: libnotmuch-dev\r
200 Version: 0.18.2-1\r
201 Severity: important\r
202 \r
203 In the API documentation for notmuch_database_close() it says:\r
204 \r
205  * After notmuch_database_close has been called, calls to other\r
206  * functions on objects derived from this database may either behave\r
207  * as if the database had not been closed (e.g., if the required data\r
208  * has been cached) or may fail with a\r
209  * NOTMUCH_STATUS_XAPIAN_EXCEPTION.\r
210 \r
211 However, if you call notmuch_database_close() on a database and then\r
212 call notmuch_database_add_message(), it doesn't fail nicely with a\r
213 NOTMUCH_STATUS_XAPIAN_EXCEPTION, it segfaults.\r
214 \r
215 This should either be fixed so it doesn't crash, as documented, or the\r
216 documentation should be changed to describe which functions are unsafe\r
217 to call after notmuch_database_close().\r
218 \r
219 I'm attaching a small C program to reproduce the bug. It crashes with\r
220 the following backtrace:\r
221 \r
222 (gdb) bt\r
223 #0  0xb71f3f27 in Xapian::WritableDatabase::begin_transaction(bool) ()\r
224    from /usr/lib/sse2/libxapian.so.22\r
225 #1  0xb779480d in notmuch_database_begin_atomic ()\r
226    from /usr/lib/i386-linux-gnu/libnotmuch.so.3\r
227 #2  0xb7794fa0 in notmuch_database_add_message ()\r
228    from /usr/lib/i386-linux-gnu/libnotmuch.so.3\r
229 #3  0x080488d3 in add_new_email (db=0x82b5610, \r
230     filename=0x8048b51 "/new-mail-2@example.net:2,", content=0x8048b30\r
231 "hello")\r
232     at notmuchcrash.c:27\r
233 #4  0x080489d7 in main () at notmuchcrash.c:52\r
234 \r
235 \r
236 Installed version of libxapian22: 1.2.19-1+deb8u1\r
237 \r
238 \r
239 -- System Information:\r
240 Debian Release: 8.5\r
241   APT prefers stable-updates\r
242   APT policy: (500, 'stable-updates'), (500, 'stable')\r
243 Architecture: i386 (i686)\r
244 \r
245 Kernel: Linux 3.16.0-4-686-pae (SMP w/2 CPU cores)\r
246 Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)\r
247 Shell: /bin/sh linked to /bin/dash\r
248 Init: systemd (via /run/systemd/system)\r
249 \r
250 Versions of packages libnotmuch-dev depends on:\r
251 ii  libnotmuch3  0.18.2-1\r
252 \r
253 libnotmuch-dev recommends no packages.\r
254 \r
255 libnotmuch-dev suggests no packages.\r
256 \r
257 -- no debconf information\r
258 \r
259 --==-=-=\r
260 Content-Type: text/x-csrc; charset=utf-8; name=notmuchcrash.c\r
261 Content-Disposition: attachment; filename=notmuchcrash.c\r
262 \r
263 /* Compile with:\r
264    gcc -g -std=c99 -Wall -Werror -o notmuchcrash -lnotmuch notmuchcrash.c\r
265 */\r
266 \r
267 #define _POSIX_C_SOURCE 200809L\r
268 \r
269 #include <stdio.h>\r
270 #include <stdlib.h>\r
271 #include <string.h>\r
272 \r
273 #include <notmuch.h>\r
274 \r
275 \r
276 #define DIE(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0)\r
277 \r
278 \r
279 void add_new_email(notmuch_database_t* db,\r
280                    char const* filename, char const* content) {\r
281   char mail_path[64];\r
282   strcpy(mail_path, notmuch_database_get_path(db));\r
283   strcat(mail_path, filename);\r
284   FILE* mf = fopen(mail_path, "w+");\r
285   if (!mf) DIE("Failed to open mail file");\r
286   if (fwrite(content, strlen(content), 1, mf) != 1)\r
287     DIE("Failed to write mail");\r
288   if (fclose(mf)) DIE("Failed to close file");\r
289   if (notmuch_database_add_message(db, mail_path, NULL) !=\r
290       NOTMUCH_STATUS_FILE_NOT_EMAIL)\r
291     DIE("Something went wrong when adding the email");\r
292 }\r
293 \r
294 \r
295 int main() {\r
296 \r
297   /* Create new database. */\r
298   char db_path[32];\r
299   strcpy(db_path, "/tmp/notmuchcrash-XXXXXX");\r
300   if (!mkdtemp(db_path)) DIE("Failed to create unique directory");\r
301   notmuch_database_t* db;\r
302   if (notmuch_database_create(db_path, &db)) DIE("Failed to create database");\r
303 \r
304   /* This doesn't have to be a valid email, it will crash either way. */\r
305   char const* mail_data = "hello";\r
306 \r
307   /* First, try to add a file before closing. */\r
308   add_new_email(db, "/new-mail-1@example.net:2,", mail_data);\r
309   \r
310   /* Close the database. */\r
311   notmuch_database_close(db);\r
312 \r
313   /* Now try again. This will crash. */\r
314   add_new_email(db, "/new-mail-2@example.net:2,", mail_data);\r
315   \r
316   return 0;\r
317 }\r
318 \r
319 --==-=-=\r
320 Content-Type: text/plain; charset=utf-8\r
321 Content-Disposition: inline\r
322 \r
323 _______________________________________________\r
324 notmuch mailing list\r
325 notmuch@notmuchmail.org\r
326 https://notmuchmail.org/mailman/listinfo/notmuch\r
327 \r
328 --==-=-=--\r