Re: bug#6214: 23.1; json-read-string crashes emacs with long string
authorChong Yidong <cyd@stupidchicken.com>
Mon, 16 Aug 2010 17:40:13 +0000 (13:40 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:12 +0000 (09:37 -0800)
4a/e674c49493dbd16746bdc3e3560b71bbb82ddd [new file with mode: 0644]

diff --git a/4a/e674c49493dbd16746bdc3e3560b71bbb82ddd b/4a/e674c49493dbd16746bdc3e3560b71bbb82ddd
new file mode 100644 (file)
index 0000000..199d570
--- /dev/null
@@ -0,0 +1,146 @@
+Return-Path: <cyd@stupidchicken.com>\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 38E6340BC61\r
+       for <notmuch@notmuchmail.org>; Mon, 16 Aug 2010 10:41:27 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9] autolearn=unavailable\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 KzLGM+cfbwQ0 for <notmuch@notmuchmail.org>;\r
+       Mon, 16 Aug 2010 10:41:16 -0700 (PDT)\r
+Received: from pantheon-po45.its.yale.edu (pantheon-po45.its.yale.edu\r
+       [130.132.50.79])\r
+       by olra.theworths.org (Postfix) with ESMTP id D197840BC64\r
+       for <notmuch@notmuchmail.org>; Mon, 16 Aug 2010 10:41:16 -0700 (PDT)\r
+Received: from furry ([64.134.241.146]) (authenticated bits=0)\r
+       by pantheon-po45.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id\r
+       o7GHekVB003001\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT);\r
+       Mon, 16 Aug 2010 13:40:49 -0400\r
+Received: by furry (Postfix, from userid 1000)\r
+       id 71ED6C013; Mon, 16 Aug 2010 13:40:13 -0400 (EDT)\r
+From: Chong Yidong <cyd@stupidchicken.com>\r
+To: Michal Sojka <sojkam1@fel.cvut.cz>\r
+Subject: Re: bug#6214: 23.1; json-read-string crashes emacs with long string\r
+References: <87pr0t5h1q.fsf@yoom.home.cworth.org>\r
+       <87fx1pkrsh.fsf@stupidchicken.com> <87tymzv6ga.fsf@steelpick.2x.cz>\r
+       <878w4afozw.fsf@stupidchicken.com> <87sk2hbq3s.fsf@steelpick.2x.cz>\r
+       <8739ug3mrr.fsf@stupidchicken.com> <87r5i02uo7.fsf@steelpick.2x.cz>\r
+Date: Mon, 16 Aug 2010 13:40:13 -0400\r
+In-Reply-To: <87r5i02uo7.fsf@steelpick.2x.cz> (Michal Sojka's message of "Sun,\r
+       15 Aug 2010 09:37:28 +0200")\r
+Message-ID: <874oeuv4le.fsf@stupidchicken.com>\r
+User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed)\r
+Cc: 6214@debbugs.gnu.org, 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: Mon, 16 Aug 2010 17:41:27 -0000\r
+\r
+Thanks, that is a useful backtrace.  Could you apply this patch and see\r
+if it fixes the problem?\r
+\r
+\r
+=== modified file 'src/eval.c'\r
+*** src/eval.c 2010-08-06 19:07:16 +0000\r
+--- src/eval.c 2010-08-16 17:37:22 +0000\r
+***************\r
+*** 2430,2437 ****\r
+    register int i, numargs;\r
+    register Lisp_Object spread_arg;\r
+    register Lisp_Object *funcall_args;\r
+!   Lisp_Object fun;\r
+    struct gcpro gcpro1;\r
+  \r
+    fun = args [0];\r
+    funcall_args = 0;\r
+--- 2430,2438 ----\r
+    register int i, numargs;\r
+    register Lisp_Object spread_arg;\r
+    register Lisp_Object *funcall_args;\r
+!   Lisp_Object fun, retval;\r
+    struct gcpro gcpro1;\r
++   USE_SAFE_ALLOCA;\r
+  \r
+    fun = args [0];\r
+    funcall_args = 0;\r
+***************\r
+*** 2470,2477 ****\r
+       {\r
+         /* Avoid making funcall cons up a yet another new vector of arguments\r
+            by explicitly supplying nil's for optional values */\r
+!        funcall_args = (Lisp_Object *) alloca ((1 + XSUBR (fun)->max_args)\r
+!                                               * sizeof (Lisp_Object));\r
+         for (i = numargs; i < XSUBR (fun)->max_args;)\r
+           funcall_args[++i] = Qnil;\r
+         GCPRO1 (*funcall_args);\r
+--- 2471,2478 ----\r
+       {\r
+         /* Avoid making funcall cons up a yet another new vector of arguments\r
+            by explicitly supplying nil's for optional values */\r
+!        SAFE_ALLOCA (funcall_args, Lisp_Object *, ((1 + XSUBR (fun)->max_args)\r
+!                                                   * sizeof (Lisp_Object)));\r
+         for (i = numargs; i < XSUBR (fun)->max_args;)\r
+           funcall_args[++i] = Qnil;\r
+         GCPRO1 (*funcall_args);\r
+***************\r
+*** 2483,2490 ****\r
+       function itself as well as its arguments.  */\r
+    if (!funcall_args)\r
+      {\r
+!       funcall_args = (Lisp_Object *) alloca ((1 + numargs)\r
+!                                           * sizeof (Lisp_Object));\r
+        GCPRO1 (*funcall_args);\r
+        gcpro1.nvars = 1 + numargs;\r
+      }\r
+--- 2484,2491 ----\r
+       function itself as well as its arguments.  */\r
+    if (!funcall_args)\r
+      {\r
+!       SAFE_ALLOCA (funcall_args, Lisp_Object *, ((1 + numargs)\r
+!                                               * sizeof (Lisp_Object)));\r
+        GCPRO1 (*funcall_args);\r
+        gcpro1.nvars = 1 + numargs;\r
+      }\r
+***************\r
+*** 2500,2506 ****\r
+      }\r
+  \r
+    /* By convention, the caller needs to gcpro Ffuncall's args.  */\r
+!   RETURN_UNGCPRO (Ffuncall (gcpro1.nvars, funcall_args));\r
+  }\r
+  \f\r
+\r
+  /* Run hook variables in various ways.  */\r
+--- 2501,2511 ----\r
+      }\r
+  \r
+    /* By convention, the caller needs to gcpro Ffuncall's args.  */\r
+!   retval = Ffuncall (gcpro1.nvars, funcall_args);\r
+!   UNGCPRO;\r
+!   SAFE_FREE ();\r
+! \r
+!   return retval;\r
+  }\r
+  \f\r
+\r
+  /* Run hook variables in various ways.  */\r
+\r