23.1; json-read-string crashes emacs with long string
authorCarl Worth <cworth@cworth.org>
Tue, 18 May 2010 16:08:17 +0000 (09:08 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:03 +0000 (09:37 -0800)
b9/dfbbd2fc0c676ecd0862e00853cc8edfad802e [new file with mode: 0644]

diff --git a/b9/dfbbd2fc0c676ecd0862e00853cc8edfad802e b/b9/dfbbd2fc0c676ecd0862e00853cc8edfad802e
new file mode 100644 (file)
index 0000000..0791f7d
--- /dev/null
@@ -0,0 +1,111 @@
+Return-Path: <cworth@cworth.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 D841D4196F2\r
+       for <notmuch@notmuchmail.org>; Tue, 18 May 2010 09:08:28 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.9 tagged_above=-999 required=5\r
+       tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=ham\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 7e0wKEkrUm-i; Tue, 18 May 2010 09:08:17 -0700 (PDT)\r
+Received: from yoom.home.cworth.org (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7BA644196F0;\r
+       Tue, 18 May 2010 09:08:17 -0700 (PDT)\r
+Received: by yoom.home.cworth.org (Postfix, from userid 1000)\r
+       id 111F5568E21; Tue, 18 May 2010 09:08:17 -0700 (PDT)\r
+From: Carl Worth <cworth@cworth.org>\r
+To: bug-gnu-emacs@gnu.org\r
+Subject: 23.1; json-read-string crashes emacs with long string\r
+User-Agent: Notmuch/0.3-7-g2baa576 (http://notmuchmail.org) Emacs/23.1.1\r
+       (i486-pc-linux-gnu)\r
+Date: Tue, 18 May 2010 09:08:17 -0700\r
+Message-ID: <87pr0t5h1q.fsf@yoom.home.cworth.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Cc: Notmuch mailing list <notmuch@notmuchmail.org>\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: Tue, 18 May 2010 16:08:30 -0000\r
+\r
+> Please describe exactly what actions triggered the bug\r
+> and the precise symptoms of the bug:\r
+\r
+A user of the emacs-based mail client, Notmuch [*], found that\r
+attempting to display a particular message would consistently\r
+causes a segmentation fault in emacs.\r
+\r
+I tracked this down to calling `json-read-string' with a very long\r
+string, (roughly 1 million characters). Rather than including that\r
+enormous string in this message, here's a little snippet of emacs lisp\r
+that creates and reads such a string. So, if evaluated, this code should\r
+trigger the segmentation fault, (assuming a copy of GPLv3 exists at\r
+/usr/share/emacs/23.1/etc/COPYING---adjust the filename if necessary).\r
+\r
+;; Caution: Evaluating the block below has been known to crash emacs\r
+(with-temp-buffer\r
+  (require 'json)\r
+  ;; First we just need a lot of text. 32 copies of GPLv3 seems to do it\r
+  (dotimes (i 32)\r
+    (insert-file "/usr/share/emacs/23.1/etc/COPYING"))\r
+  ;; Now create a buffer with a json-encoded version of the text\r
+  (let ((json-string (json-encode-string (buffer-string))))\r
+    (with-temp-buffer\r
+      (insert json-string)\r
+      (goto-char (point-min))\r
+      ;; And try to read the string. This triggers the segfault.\r
+      (json-read-string))))\r
+\r
+> If Emacs crashed, and you have the Emacs process in the gdb debugger,\r
+> please include the output from the following gdb commands:\r
+>    `bt full' and `xbacktrace'.\r
+\r
+I haven't attempted to debug this within gdb yet, (I'll have to get my\r
+hands on a build of emacs with debugging symbols first). But I wanted to\r
+share things right away, so that perhaps someone else could do further\r
+debugging and follow up.\r
+\r
+In the meantime, notmuch folks, if you've got a good idea for modifying\r
+notmuch to avoid this bug I'd be glad to hear it. Adjust followups to\r
+include the notmuch list and not the gnu.org bug address as appropriate.\r
+\r
+-Carl\r
+\r
+[*] http://notmuchmail.org\r
+\r
+PS. Here are some of the details provided by `report-emacs-bug':\r
+\r
+In GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.18.2)\r
+ of 2010-01-26 on raven, modified by Debian\r
+Windowing system distributor `The X.Org Foundation', version 11.0.10799001\r
+configured using `configure  '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''\r
+\r
+Important settings:\r
+  value of $LC_ALL: nil\r
+  value of $LC_COLLATE: nil\r
+  value of $LC_CTYPE: nil\r
+  value of $LC_MESSAGES: nil\r
+  value of $LC_MONETARY: nil\r
+  value of $LC_NUMERIC: nil\r
+  value of $LC_TIME: nil\r
+  value of $LANG: en_US.UTF-8\r
+  value of $XMODIFIERS: nil\r
+  locale-coding-system: utf-8-unix\r
+  default-enable-multibyte-characters: t\r
+\r
+-- \r
+carl.d.worth@intel.com\r