From: Jameson Graef Rollins Date: Tue, 7 Aug 2012 08:08:40 +0000 (+1700) Subject: Re: Segmentation fault in notmuch search --format=json X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=56d68512bac6c50daf777e72f2baa1b6899ca570;p=notmuch-archives.git Re: Segmentation fault in notmuch search --format=json --- diff --git a/92/2e8823a38ea293e36fa04b5e943b514f7f3ed0 b/92/2e8823a38ea293e36fa04b5e943b514f7f3ed0 new file mode 100644 index 000000000..bcf979b3e --- /dev/null +++ b/92/2e8823a38ea293e36fa04b5e943b514f7f3ed0 @@ -0,0 +1,126 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id F2951431FC4 + for ; Tue, 7 Aug 2012 01:08:52 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.29 +X-Spam-Level: +X-Spam-Status: No, score=-2.29 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_MED=-2.3, T_MIME_NO_TEXT=0.01] 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 6GU7YWjmaDq5 for ; + Tue, 7 Aug 2012 01:08:51 -0700 (PDT) +Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu + [131.215.239.19]) + by olra.theworths.org (Postfix) with ESMTP id 01A9D431FAF + for ; Tue, 7 Aug 2012 01:08:50 -0700 (PDT) +Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1]) + by earth-doxen-postvirus (Postfix) with ESMTP id 7604E66E00C2; + Tue, 7 Aug 2012 01:08:48 -0700 (PDT) +X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new +Received: from finestructure.net (unknown [76.89.192.57]) + (Authenticated sender: jrollins) + by earth-doxen-submit (Postfix) with ESMTP id 519BD66E00A9; + Tue, 7 Aug 2012 01:08:44 -0700 (PDT) +Received: by finestructure.net (Postfix, from userid 1000) + id C1D5A55B; Tue, 7 Aug 2012 01:08:43 -0700 (PDT) +From: Jameson Graef Rollins +To: Mark Walters , + Ben Gamari , notmuch@notmuchmail.org +Subject: Re: Segmentation fault in notmuch search --format=json +In-Reply-To: <878vdrp4d9.fsf@qmul.ac.uk> +References: <871ujjuu2z.fsf@gmail.com> <878vdrp4d9.fsf@qmul.ac.uk> +User-Agent: Notmuch/0.13.2+136~g6c0183b (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 07 Aug 2012 01:08:40 -0700 +Message-ID: <87pq73jf92.fsf@servo.finestructure.net> +MIME-Version: 1.0 +Content-Type: multipart/signed; boundary="=-=-="; + micalg=pgp-sha256; protocol="application/pgp-signature" +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: Tue, 07 Aug 2012 08:08:53 -0000 + +--=-=-= +Content-Transfer-Encoding: quoted-printable + +On Tue, Aug 07 2012, Mark Walters wrote: +> On Tue, 07 Aug 2012, Ben Gamari wrote: +>> It seems some messages trigger a segmentation fault in +>> `do_search_threads()`. It appears the problem occurs (at least) when +>> `authors` is NULL. +> +> Hi thanks for the bug report and detailed debugging. I think I can see +> the problem and there is a test patch to fix it below, and this does +> appear to be a regression. +> +> In json.c the function json_quote_str explicitly checks/allows for a +> NULL pointer passed as a string and pretends it is just an empty +> string. That behaviour was lost in the move to structured formatters. +> +> A simple fix is to put this check for a null pointer in json_string in +> sprinter-json.c which is what this patch does. + +Thanks Mark! I was experiencing the same problem and this fixed the +issue before I even got a chance to respond. This seems like a fine +solution. + +> Incidentally this is the second time this bug has appeared:=20 +> +> commit cacefbf3d6dd5bce0b60b3cdfce29bfa371dfaea +> Author: David Edmondson +> Date: Tue Apr 6 08:24:00 2010 +0100 +> +> json: Avoid calling strlen(NULL) +>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 +> MIME parts may have no filename, which previously res= +ulted in calling +> strlen(NULL). +> +> so it really might be worth having a test for it! + +Indeed! I think the problematic email in this case was one with no +subject. + +> Finally, I think nothing in json.c is used anymore so perhaps it +> could be removed. + +Agreed. + +jamie. + +--=-=-= +Content-Type: application/pgp-signature + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.12 (GNU/Linux) + +iQIcBAEBCAAGBQJQIM0JAAoJEO00zqvie6q8C84P/0+M3A6/vj9qdDrQRaOOvFRR +p6vNJ+ebIZegrtS2DzFan7Idy9v+CNnTRt9hEJUO+xJcVZcD2LnwFo43DBeYyAhn +BTDR2IjvHDPKGg3J7uYe7DAjhZdfIJd5BYbXkVd3in3j6EQbQsXiiEua4wqyn3E8 +gQB6zZXDEGY9F7Bj/v+PhpNVXNJOfS64QVIc2fWyMUg8Lrj12dYYpEnNS/21pj7S +GbCYFgtcdSk4ODqA3gLoVeZqJ/io//w33hS/P5decwQJkceSNBVppQ7KXImKQqlg +6iXyz9IjDtyBMqVaBuDutWwwJcYxa1+AdKpobyi0RgfcGfX2YKDjqHA1DPo142pz +fVNUviRv8Q2UxIxxKC4BvQGcftUmwlPG+6OlFV9lUL6NAgkf6tIg1vMo8OFm88Y1 +ibbxBPe5hCOqq1K+ELUEV8E2VVFBlEBlVyfe9/piWO507bkCAAIubzCV12lX3KHe +otJ2VleJd3Y6/49E/6zV9AGLavEJXjaINtQyNVi7m4yf/MVWdgpwE4hgZxUqF5sJ +aXggn6ppJtGsTtKTC3/Nfu62TImzcEM9OHej5NEO/xU+rTBI6ZUKNNYXMBtv6aYY +IlST5W78DqcW9SJvGJWP+ZbcX8U027yShRy+s8v4uklxUNjcFFjeKvxl35HAoQ00 +GYMob3scnwRD67mnAWUd +=DuIz +-----END PGP SIGNATURE----- +--=-=-=--