GNU bug report logs - #16999
calc crashes when computation limit is increased

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Florian Beck <fb@HIDDEN>; dated Wed, 12 Mar 2014 18:56:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 16999 <at> debbugs.gnu.org:


Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 22:10:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 13 18:10:44 2014
Received: from localhost ([127.0.0.1]:36210 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WODpr-0004k7-9B
	for submit <at> debbugs.gnu.org; Thu, 13 Mar 2014 18:10:43 -0400
Received: from mercure.iro.umontreal.ca ([132.204.24.67]:60413)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <monnier@HIDDEN>) id 1WODpo-0004jt-RZ
 for 16999 <at> debbugs.gnu.org; Thu, 13 Mar 2014 18:10:41 -0400
Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca
 [132.204.27.50])
 by mercure.iro.umontreal.ca (Postfix) with ESMTP id 1E97F84DA8;
 Thu, 13 Mar 2014 18:10:40 -0400 (EDT)
Received: from lechon.iro.umontreal.ca (lechon.iro.umontreal.ca
 [132.204.27.242])
 by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id B0F921E5B74;
 Thu, 13 Mar 2014 18:10:05 -0400 (EDT)
Received: by lechon.iro.umontreal.ca (Postfix, from userid 20848)
 id 83946B416B; Thu, 13 Mar 2014 18:10:05 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Florian Beck <fb@HIDDEN>
Subject: Re: bug#16999: calc crashes when computation limit is increased
Message-ID: <jwviorhbvio.fsf-monnier+emacsbugs@HIDDEN>
References: <5320A7D9.3000802@HIDDEN> <87vbvjca0w.fsf@HIDDEN>
 <53213E92.9010506@HIDDEN>
 <jwvwqfyxlkg.fsf-monnier+emacsbugs@HIDDEN>
 <5321BCB2.8080605@HIDDEN>
Date: Thu, 13 Mar 2014 18:10:05 -0400
In-Reply-To: <5321BCB2.8080605@HIDDEN> (Florian Beck's message of "Thu, 
 13 Mar 2014 15:12:02 +0100")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-DIRO-MailScanner-Information: Please contact the ISP for more information
X-DIRO-MailScanner: Found to be clean
X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel,
 SpamAssassin (score=-2.82, requis 5, autolearn=not spam,
 ALL_TRUSTED -2.82, MC_TSTLAST 0.00)
X-DIRO-MailScanner-From: monnier@HIDDEN
X-Spam-Status: No
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 16999
Cc: Dmitry Antipov <dmantipov@HIDDEN>, 16999 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

> Maybe calc shouldn't bump them too high, then.

Indeed, it shouldn't.


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.

Message received at 16999 <at> debbugs.gnu.org:


Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 21:16:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 13 17:16:02 2014
Received: from localhost ([127.0.0.1]:36203 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WOCyv-00034w-SF
	for submit <at> debbugs.gnu.org; Thu, 13 Mar 2014 17:16:02 -0400
Received: from mail-oa0-f43.google.com ([209.85.219.43]:49147)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <jay.p.belanger@HIDDEN>) id 1WOCyt-00034g-TF
 for 16999 <at> debbugs.gnu.org; Thu, 13 Mar 2014 17:16:00 -0400
Received: by mail-oa0-f43.google.com with SMTP id g12so1713257oah.2
 for <16999 <at> debbugs.gnu.org>; Thu, 13 Mar 2014 14:15:59 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=from:to:cc:subject:references:reply-to:cc:date:in-reply-to
 :message-id:user-agent:mime-version:content-type
 :content-transfer-encoding;
 bh=Nqh8gdTfRFIDXtyaZmuSNzM6rGOOY9FFpIycWNtq3PA=;
 b=uWVKwX+iUXBEVeyDQL1JzW1Y+Ip7D4rUwBOPx+JL+ixnMxSAuH4tmqMMNGssgYroWS
 hVAe5OTjLSE6P2bnGSrL0gosgRXNOpiStcR5ulJc69PnDSt5o3TKrXlsc8QyKIlKVhsE
 mUjYygnLDFb+7c3iMGbOL1CcNfpq+6Yky7KZ445z+6nDecufSMqYqmFa1/INxFjeJo0A
 gUahpdu4QSJ3VXGhT4p10bdDCLry/N9eRk5dcC7ek+lWENwxDuamPUhzHc64gvX7bbXO
 clR0jhxOFS60Q+Vs0AjWo7b6Crur6L/BvmVQhEid2Gp794dxZKDyVA4wwHMhW/A+Pfn8
 iq6g==
X-Received: by 10.182.246.39 with SMTP id xt7mr3347392obc.16.1394745359185;
 Thu, 13 Mar 2014 14:15:59 -0700 (PDT)
Received: from belanger-home (184-155-87-143.cpe.cableone.net.
 [184.155.87.143])
 by mx.google.com with ESMTPSA id j9sm82221obh.23.2014.03.13.14.15.57
 for <multiple recipients>
 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
 Thu, 13 Mar 2014 14:15:58 -0700 (PDT)
From: Jay Belanger <jay.p.belanger@HIDDEN>
To: Florian Beck <fb@HIDDEN>
Subject: Re: bug#16999: calc crashes when computation limit is increased
References: <5320A7D9.3000802@HIDDEN> <87vbvjca0w.fsf@HIDDEN>
 <53213E92.9010506@HIDDEN>
 <jwvwqfyxlkg.fsf-monnier+emacsbugs@HIDDEN>
 <5321BCB2.8080605@HIDDEN>
Date: Thu, 13 Mar 2014 16:15:56 -0500
In-Reply-To: <5321BCB2.8080605@HIDDEN> (Florian Beck's message of "Thu, 
 13 Mar 2014 15:12:02 +0100")
Message-ID: <87r465dckz.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 16999
Cc: jay.p.belanger@HIDDEN, Dmitry Antipov <dmantipov@HIDDEN>,
 16999 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: jay.p.belanger@HIDDEN
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)


>> There is, in the form of max-specpdl-size and max-lisp-eval-depth.
>> If you bump them up too high, you're asking for trouble.
>
> Maybe calc shouldn't bump them too high, then.

The Elisp manual has a warning about bumping them too high; perhaps the
Calc manual should have one also.  But this seems more like an Emacs
issue than specifically a Calc issue, so any other fixes should probably
take place out of Calc.

Dmitry has started a separate discussion on handling this issue; good
deal.=20

> Would I start calc, repetedly press "M" and then crash emacs =E2=80=93 we=
ll,
> maybe I was asking for trouble.

The main culprit here is the infinite loop itself, which needs to be
fixed.  Without that, you wouldn't have had any problems.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.

Message received at 16999 <at> debbugs.gnu.org:


Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 16:57:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 13 12:57:03 2014
Received: from localhost ([127.0.0.1]:36091 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WO8wJ-0003Jn-3H
	for submit <at> debbugs.gnu.org; Thu, 13 Mar 2014 12:57:03 -0400
Received: from mtaout22.012.net.il ([80.179.55.172]:62182)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1WO8wG-0003JD-6G
 for 16999 <at> debbugs.gnu.org; Thu, 13 Mar 2014 12:57:01 -0400
Received: from conversion-daemon.a-mtaout22.012.net.il by
 a-mtaout22.012.net.il (HyperSendmail v2007.08) id
 <0N2D00600WB4ZF00@HIDDEN> for 16999 <at> debbugs.gnu.org;
 Thu, 13 Mar 2014 18:56:58 +0200 (IST)
Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0N2D0063CWEXI8C0@HIDDEN>;
 Thu, 13 Mar 2014 18:56:58 +0200 (IST)
Date: Thu, 13 Mar 2014 18:56:53 +0200
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#16999: calc crashes when computation limit is increased
In-reply-to: <53217656.7080608@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Dmitry Antipov <dmantipov@HIDDEN>
Message-id: <834n32niju.fsf@HIDDEN>
References: <5320A7D9.3000802@HIDDEN> <87vbvjca0w.fsf@HIDDEN>
 <53213E92.9010506@HIDDEN> <53217656.7080608@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 16999
Cc: eggert@HIDDEN, 16999 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> Date: Thu, 13 Mar 2014 13:11:50 +0400
> From: Dmitry Antipov <dmantipov@HIDDEN>
> CC: Paul Eggert <eggert@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
> 
> On 03/13/2014 09:13 AM, Dmitry Antipov wrote:
> 
> > Perhaps there should be a kind of protection against this. For example,
> > eval_sub can check current stack depth against getrlimit (RLIMIT_STACK,...).
> 
> This is rather simple on general *NIX. But:
> 
> 1) it should be implemented for MS-Windows and OSX too if we really need this;

It should be easy enough to emulate on MS-Windows getrlimit that
supports RLIMIT_STACK.  Let me know if you want me to do that (should
ideally be ready before it is used, to avoid breaking the build).

> 2) Linux has prlimit to tweak limits of another process at run time,
>     so actual limit should be checked each time eval_sub is called, thus
>     introducing a (minor?) slowdown.

I'm not sure we should bother.  We already use getrlimit/setrlimit for
making sure the stack is large enough to accommodate re_max_failures.
We do that only once, at startup, and never look back.  And yet I
don't think we've seen regexp related crashes that would point to
stack overflow.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.

Message received at 16999 <at> debbugs.gnu.org:


Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 14:30:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 13 10:30:47 2014
Received: from localhost ([127.0.0.1]:35996 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WO6ek-00074r-Jp
	for submit <at> debbugs.gnu.org; Thu, 13 Mar 2014 10:30:47 -0400
Received: from forward14.mail.yandex.net ([95.108.130.92]:56353)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dmantipov@HIDDEN>) id 1WO6eg-00074c-QW
 for 16999 <at> debbugs.gnu.org; Thu, 13 Mar 2014 10:30:44 -0400
Received: from smtp14.mail.yandex.net (smtp14.mail.yandex.net [95.108.131.192])
 by forward14.mail.yandex.net (Yandex) with ESMTP id 5E8F81981565;
 Thu, 13 Mar 2014 18:30:41 +0400 (MSK)
Received: from smtp14.mail.yandex.net (localhost [127.0.0.1])
 by smtp14.mail.yandex.net (Yandex) with ESMTP id 20EA61B608AA;
 Thu, 13 Mar 2014 18:30:41 +0400 (MSK)
Received: from unknown (unknown [37.139.80.10])
 by smtp14.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id gQF9XRe05S-UecGkRMF; 
 Thu, 13 Mar 2014 18:30:40 +0400
 (using TLSv1 with cipher AES128-SHA (128/128 bits))
 (Client certificate not present)
X-Yandex-Uniq: 105dde94-2c33-4deb-b69c-0bb3480f9e64
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1394721040; bh=l/NNbBPDXS7sa/R6s9vQIjIwiKjz/AbzArsT5gSrnmk=;
 h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:
 References:In-Reply-To:Content-Type;
 b=ugKKfC/el6z7a00ZFA5Gw65WwyGx+TWofZEi+wLOMbukVgES5zQwK/QNhcVZH17+/
 sprVv/CvyRyt2fg9NbNO6n/BY7UF+YaMhSPi6TlBaoOPOcPHSyeFZNdt12XFgppJHF
 ryUrutz+jkYkiKq5U4LjJm/zmKMgYbynHO5/sf1M=
Authentication-Results: smtp14.mail.yandex.net; dkim=pass header.i=@yandex.ru
Message-ID: <5321C110.9060605@HIDDEN>
Date: Thu, 13 Mar 2014 18:30:40 +0400
From: Dmitry Antipov <dmantipov@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:24.0) Gecko/20100101 Thunderbird/24.3.0
MIME-Version: 1.0
To: Florian Beck <fb@HIDDEN>
Subject: Re: bug#16999: calc crashes when computation limit is increased
References: <5320A7D9.3000802@HIDDEN>	<87vbvjca0w.fsf@HIDDEN>	<53213E92.9010506@HIDDEN>	<53217656.7080608@HIDDEN>
 <5321BB4E.4080009@HIDDEN>
In-Reply-To: <5321BB4E.4080009@HIDDEN>
Content-Type: multipart/mixed; boundary="------------090508040303060105010903"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 16999
Cc: 16999 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

This is a multi-part message in MIME format.
--------------090508040303060105010903
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 03/13/2014 06:06 PM, Florian Beck wrote:

> Sorry, this doesn't work for me. (I applied the patch and bootstrapped, but I still get the crash.)

Oops, the guard should be installed in Ffuncall too...

Dmitry


--------------090508040303060105010903
Content-Type: text/x-patch;
 name="error_if_c_stack_overflow_fixed.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="error_if_c_stack_overflow_fixed.patch"

=== modified file 'src/eval.c'
--- src/eval.c	2014-02-10 09:48:17 +0000
+++ src/eval.c	2014-03-13 14:27:14 +0000
@@ -33,6 +33,10 @@
 #include "xterm.h"
 #endif
 
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
 /* Chain of condition and catch handlers currently in effect.  */
 
 struct handler *handlerlist;
@@ -240,6 +244,13 @@
 
 static struct handler handlerlist_sentinel;
 
+/* C stack overflow protection.  */
+
+#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_STACK)
+/* Current C stack slimit.  */
+static struct rlimit stack_limit;
+#endif
+
 void
 init_eval (void)
 {
@@ -262,6 +273,10 @@
 #endif
   /* This is less than the initial value of num_nonmacro_input_events.  */
   when_entered_debugger = -1;
+#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_STACK)
+  if (getrlimit (RLIMIT_STACK, &stack_limit))
+    emacs_abort ();
+#endif  
 }
 
 /* Unwind-protect function used by call_debugger.  */
@@ -2060,6 +2075,19 @@
   Lisp_Object funcar;
   struct gcpro gcpro1, gcpro2, gcpro3;
 
+#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_STACK)
+  ptrdiff_t stack_size;
+  char stack_top_variable;
+  const ptrdiff_t stack_extra = 128 * 1024;
+
+  if (&stack_top_variable < stack_bottom)
+    stack_size = stack_bottom - &stack_top_variable;
+  else
+    stack_size = &stack_top_variable - stack_bottom;
+  if (stack_size + stack_extra > stack_limit.rlim_cur)
+    error ("Attempt to overflow C stack");
+#endif /* HAVE_GETRLIMIT && RLIMIT_STACK */
+  
   if (SYMBOLP (form))
     {
       /* Look up its binding in the lexical environment.
@@ -2749,6 +2777,19 @@
   register Lisp_Object *internal_args;
   ptrdiff_t i;
 
+#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_STACK)
+  ptrdiff_t stack_size;
+  char stack_top_variable;
+  const ptrdiff_t stack_extra = 128 * 1024;
+
+  if (&stack_top_variable < stack_bottom)
+    stack_size = stack_bottom - &stack_top_variable;
+  else
+    stack_size = &stack_top_variable - stack_bottom;
+  if (stack_size + stack_extra > stack_limit.rlim_cur)
+    error ("Attempt to overflow C stack");
+#endif /* HAVE_GETRLIMIT && RLIMIT_STACK */
+
   QUIT;
 
   if (++lisp_eval_depth > max_lisp_eval_depth)


--------------090508040303060105010903--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.

Message received at 16999 <at> debbugs.gnu.org:


Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 14:12:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 13 10:12:08 2014
Received: from localhost ([127.0.0.1]:35969 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WO6Mi-0006TP-1i
	for submit <at> debbugs.gnu.org; Thu, 13 Mar 2014 10:12:08 -0400
Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.161]:8656)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <fb@HIDDEN>) id 1WO6Mg-0006TH-9u
 for 16999 <at> debbugs.gnu.org; Thu, 13 Mar 2014 10:12:06 -0400
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1394719925; l=588;
 s=domk; d=streitblatt.de;
 h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References:
 Subject:CC:To:MIME-Version:From:Date:X-RZG-CLASS-ID:X-RZG-AUTH;
 bh=0QOA53WAQpaA9JDfv1w0fqA62iM=;
 b=knOfBgEMiThQZQCJw9bcBnBCdmBuAnAnCJK5BZHz1tELDbtRfP4iB/5Ip0fh9rszOtS
 r8uoVISXnBrK6TBH9HmR9bvon3sp7gZtH+e8bRPK2uMZAyUVpad2mb+iClMY0DCGLi1Go
 fWrp3Vt2dY7IZmVprj8YiGzNNUc7Siukq0k=
X-RZG-AUTH: :KmALZ0mpdbGonPxw7gDkop508XQjelhLxGYn4B74/iddlkME3ssvHN/NX3uKqg+oBr7XK77Vgq4U
X-RZG-CLASS-ID: mo00
Received: from [109.43.236.208] (ip-109-43-236-208.web.vodafone.de
 [109.43.236.208]) by smtp.strato.de (RZmta 32.27 DYNA|AUTH)
 with ESMTPSA id f06362q2DEC45Id
 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
 (Client did not present a certificate);
 Thu, 13 Mar 2014 15:12:04 +0100 (CET)
Message-ID: <5321BCB2.8080605@HIDDEN>
Date: Thu, 13 Mar 2014 15:12:02 +0100
From: Florian Beck <fb@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:24.0) Gecko/20100101 Thunderbird/24.3.0
MIME-Version: 1.0
To: Stefan Monnier <monnier@HIDDEN>, 
 Dmitry Antipov <dmantipov@HIDDEN>
Subject: Re: bug#16999: calc crashes when computation limit is increased
References: <5320A7D9.3000802@HIDDEN>
 <87vbvjca0w.fsf@HIDDEN>	<53213E92.9010506@HIDDEN>
 <jwvwqfyxlkg.fsf-monnier+emacsbugs@HIDDEN>
In-Reply-To: <jwvwqfyxlkg.fsf-monnier+emacsbugs@HIDDEN>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 16999
Cc: 16999 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

On 13.03.2014 14:42, Stefan Monnier wrote:
>> Perhaps there should be a kind of protection against this.
>
> There is, in the form of max-specpdl-size and max-lisp-eval-depth.
> If you bump them up too high, you're asking for trouble.

Maybe calc shouldn't bump them too high, then.

Would I start calc, repetedly press "M" and then crash emacs  well, 
maybe I was asking for trouble. But I pressed M as suggested, then 
checked to docs, then again pressed M as suggested, then did something 
else, returned to calc, pressed M again as suggested, and so on...
-- 
Florian Beck




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.

Message received at 16999 <at> debbugs.gnu.org:


Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 14:06:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 13 10:06:15 2014
Received: from localhost ([127.0.0.1]:35965 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WO6H0-0006IS-I2
	for submit <at> debbugs.gnu.org; Thu, 13 Mar 2014 10:06:15 -0400
Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.161]:30078)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <fb@HIDDEN>) id 1WO6Gw-0006IG-Nt
 for 16999 <at> debbugs.gnu.org; Thu, 13 Mar 2014 10:06:12 -0400
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1394719569; l=383;
 s=domk; d=streitblatt.de;
 h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References:
 Subject:To:MIME-Version:From:Date:X-RZG-CLASS-ID:X-RZG-AUTH;
 bh=d+M8kFqY2z416RXJvdNrRtURHxY=;
 b=HcAYYPY0naT8cAT43qwcwjZElJPXpdgyp9Sb6a+Q86K8WcHJX9F0LeuC8QhFUxHJXI+
 J9i3DavKnE7yxFQuEEwAvZbKPzS5buleaEoqkXLHUZP0TTNgQVT+K2NiImoG+eG7/EniG
 3XYXZQuLglcj4qEbhDt0kEgx0J4jYIpdD5c=
X-RZG-AUTH: :KmALZ0mpdbGonPxw7gDkop508XQjelhLxGYn4B74/iddlkME3ssvHN/NX3uKqg+oBr7XK77Vgq4U
X-RZG-CLASS-ID: mo00
Received: from [109.43.236.208] (ip-109-43-236-208.web.vodafone.de
 [109.43.236.208]) by smtp.strato.de (RZmta 32.27 DYNA|AUTH)
 with ESMTPSA id R040d2q2DE683bl
 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
 (Client did not present a certificate);
 Thu, 13 Mar 2014 15:06:08 +0100 (CET)
Message-ID: <5321BB4E.4080009@HIDDEN>
Date: Thu, 13 Mar 2014 15:06:06 +0100
From: Florian Beck <fb@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:24.0) Gecko/20100101 Thunderbird/24.3.0
MIME-Version: 1.0
To: Dmitry Antipov <dmantipov@HIDDEN>, 16999 <at> debbugs.gnu.org
Subject: Re: bug#16999: calc crashes when computation limit is increased
References: <5320A7D9.3000802@HIDDEN>
 <87vbvjca0w.fsf@HIDDEN>	<53213E92.9010506@HIDDEN>
 <53217656.7080608@HIDDEN>
In-Reply-To: <53217656.7080608@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 16999
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

On 13.03.2014 10:11, Dmitry Antipov wrote:
> On 03/13/2014 09:13 AM, Dmitry Antipov wrote:
>
>> Perhaps there should be a kind of protection against this. For example,
>> eval_sub can check current stack depth against getrlimit
>> (RLIMIT_STACK,...).

Sorry, this doesn't work for me. (I applied the patch and bootstrapped, 
but I still get the crash.)


-- 
Florian Beck




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.

Message received at 16999 <at> debbugs.gnu.org:


Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 13:42:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 13 09:42:28 2014
Received: from localhost ([127.0.0.1]:35505 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WO5tz-0005Ur-JE
	for submit <at> debbugs.gnu.org; Thu, 13 Mar 2014 09:42:28 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.181]:60243)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <monnier@HIDDEN>) id 1WO5tt-0005Uf-KJ
 for 16999 <at> debbugs.gnu.org; Thu, 13 Mar 2014 09:42:22 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av4EABK/CFFMCppy/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtjRqDcAOkeoFegxOBSw
X-IPAS-Result: Av4EABK/CFFMCppy/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtjRqDcAOkeoFegxOBSw
X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="51711594"
Received: from 76-10-154-114.dsl.teksavvy.com (HELO pastel.home)
 ([76.10.154.114])
 by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA;
 13 Mar 2014 09:42:21 -0400
Received: by pastel.home (Postfix, from userid 20848)
 id B273D6057F; Thu, 13 Mar 2014 09:42:20 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Dmitry Antipov <dmantipov@HIDDEN>
Subject: Re: bug#16999: calc crashes when computation limit is increased
Message-ID: <jwvwqfyxlkg.fsf-monnier+emacsbugs@HIDDEN>
References: <5320A7D9.3000802@HIDDEN> <87vbvjca0w.fsf@HIDDEN>
 <53213E92.9010506@HIDDEN>
Date: Thu, 13 Mar 2014 09:42:20 -0400
In-Reply-To: <53213E92.9010506@HIDDEN> (Dmitry Antipov's message of "Thu,
 13 Mar 2014 09:13:54 +0400")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 16999
Cc: jay.p.belanger@HIDDEN, 16999 <at> debbugs.gnu.org,
 Florian Beck <fb@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.3 (/)

> Perhaps there should be a kind of protection against this.

There is, in the form of max-specpdl-size and max-lisp-eval-depth.
If you bump them up too high, you're asking for trouble.


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.

Message received at 16999 <at> debbugs.gnu.org:


Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 09:11:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 13 05:11:57 2014
Received: from localhost ([127.0.0.1]:35320 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WO1gC-0003uk-FV
	for submit <at> debbugs.gnu.org; Thu, 13 Mar 2014 05:11:56 -0400
Received: from forward12.mail.yandex.net ([95.108.130.94]:59599)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dmantipov@HIDDEN>) id 1WO1g9-0003uW-65
 for 16999 <at> debbugs.gnu.org; Thu, 13 Mar 2014 05:11:54 -0400
Received: from smtp11.mail.yandex.net (smtp11.mail.yandex.net [95.108.130.67])
 by forward12.mail.yandex.net (Yandex) with ESMTP id CC9E9C2248A;
 Thu, 13 Mar 2014 13:11:51 +0400 (MSK)
Received: from smtp11.mail.yandex.net (localhost [127.0.0.1])
 by smtp11.mail.yandex.net (Yandex) with ESMTP id 723AB7E0057;
 Thu, 13 Mar 2014 13:11:51 +0400 (MSK)
Received: from unknown (unknown [37.139.80.10])
 by smtp11.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id hdgbfp3vwY-Bo7qJ9qk; 
 Thu, 13 Mar 2014 13:11:50 +0400
 (using TLSv1 with cipher AES128-SHA (128/128 bits))
 (Client certificate not present)
X-Yandex-Uniq: dd396e24-aa5f-4ae2-af70-6dffa9b80f61
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1394701910; bh=v7dhPKVvG7IQj6Fvg7QgbldlgXSGambm0rnQ0fVa9Bc=;
 h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:
 References:In-Reply-To:Content-Type;
 b=W3fhm1ojSKHQFNurPOqH8/p/iQHa1aMkqc0u6IB0AKw5vdBvcL73vBVtwmH7ZLrgv
 8AfPdL9dh1ls9cS1maHoUPAA0FI8xii+KBSW4yaBVhjwzCgiBaBcPkEA8g71wAHrgg
 15yT7osN8AO56C9CM2OBsTf089J03BOOUjDa/obo=
Authentication-Results: smtp11.mail.yandex.net; dkim=pass header.i=@yandex.ru
Message-ID: <53217656.7080608@HIDDEN>
Date: Thu, 13 Mar 2014 13:11:50 +0400
From: Dmitry Antipov <dmantipov@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:24.0) Gecko/20100101 Thunderbird/24.3.0
MIME-Version: 1.0
To: 16999 <at> debbugs.gnu.org
Subject: Re: bug#16999: calc crashes when computation limit is increased
References: <5320A7D9.3000802@HIDDEN> <87vbvjca0w.fsf@HIDDEN>
 <53213E92.9010506@HIDDEN>
In-Reply-To: <53213E92.9010506@HIDDEN>
Content-Type: multipart/mixed; boundary="------------030105050506050607080105"
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 16999
Cc: Eli Zaretskii <eliz@HIDDEN>, Paul Eggert <eggert@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

This is a multi-part message in MIME format.
--------------030105050506050607080105
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 03/13/2014 09:13 AM, Dmitry Antipov wrote:

> Perhaps there should be a kind of protection against this. For example,
> eval_sub can check current stack depth against getrlimit (RLIMIT_STACK,...).

This is rather simple on general *NIX. But:

1) it should be implemented for MS-Windows and OSX too if we really need this;
2) Linux has prlimit to tweak limits of another process at run time,
    so actual limit should be checked each time eval_sub is called, thus
    introducing a (minor?) slowdown.

Dmitry


--------------030105050506050607080105
Content-Type: text/x-patch;
 name="error_if_c_stack_overflow.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="error_if_c_stack_overflow.patch"

=== modified file 'src/eval.c'
--- src/eval.c	2014-02-10 09:48:17 +0000
+++ src/eval.c	2014-03-13 08:59:39 +0000
@@ -33,6 +33,10 @@
 #include "xterm.h"
 #endif
 
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
 /* Chain of condition and catch handlers currently in effect.  */
 
 struct handler *handlerlist;
@@ -240,6 +244,13 @@
 
 static struct handler handlerlist_sentinel;
 
+/* C stack overflow protection.  */
+
+#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_STACK)
+/* Current C stack slimit.  */
+static struct rlimit stack_limit;
+#endif
+
 void
 init_eval (void)
 {
@@ -262,6 +273,10 @@
 #endif
   /* This is less than the initial value of num_nonmacro_input_events.  */
   when_entered_debugger = -1;
+#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_STACK)
+  if (getrlimit (RLIMIT_STACK, &stack_limit))
+    emacs_abort ();
+#endif  
 }
 
 /* Unwind-protect function used by call_debugger.  */
@@ -2060,6 +2075,19 @@
   Lisp_Object funcar;
   struct gcpro gcpro1, gcpro2, gcpro3;
 
+#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_STACK)
+  ptrdiff_t stack_size;
+  char stack_top_variable;
+  const ptrdiff_t stack_extra = 128 * 1024;
+
+  if (&stack_top_variable < stack_bottom)
+    stack_size = stack_bottom - &stack_top_variable;
+  else
+    stack_size = &stack_top_variable - stack_bottom;
+  if (stack_size + stack_extra > stack_limit.rlim_cur)
+    error ("Attempt to overflow C stack");
+#endif /* HAVE_GETRLIMIT && RLIMIT_STACK */
+  
   if (SYMBOLP (form))
     {
       /* Look up its binding in the lexical environment.


--------------030105050506050607080105--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.

Message received at 16999 <at> debbugs.gnu.org:


Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 05:14:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 13 01:14:00 2014
Received: from localhost ([127.0.0.1]:35227 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WNxxw-0004e8-93
	for submit <at> debbugs.gnu.org; Thu, 13 Mar 2014 01:14:00 -0400
Received: from forward2l.mail.yandex.net ([84.201.143.145]:53262)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dmantipov@HIDDEN>) id 1WNxxt-0004dt-8V
 for 16999 <at> debbugs.gnu.org; Thu, 13 Mar 2014 01:13:58 -0400
Received: from smtp14.mail.yandex.net (smtp14.mail.yandex.net [95.108.131.192])
 by forward2l.mail.yandex.net (Yandex) with ESMTP id BB5461AC0FB6;
 Thu, 13 Mar 2014 09:13:55 +0400 (MSK)
Received: from smtp14.mail.yandex.net (localhost [127.0.0.1])
 by smtp14.mail.yandex.net (Yandex) with ESMTP id 5444C1B60329;
 Thu, 13 Mar 2014 09:13:55 +0400 (MSK)
Received: from unknown (unknown [37.139.80.10])
 by smtp14.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id MeT4kwLEN3-Dscmftoa; 
 Thu, 13 Mar 2014 09:13:55 +0400
 (using TLSv1 with cipher AES128-SHA (128/128 bits))
 (Client certificate not present)
X-Yandex-Uniq: 68df92ce-22bf-4801-8373-b2e63c481966
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1394687635; bh=xGvwKmoOtEUGiluzbbUSEamGx8SiyX58n2BVbG3aGyI=;
 h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:
 References:In-Reply-To:Content-Type:Content-Transfer-Encoding;
 b=ezUoopkBT2zYcrO2VK7ZxbBftDixo7IyiuhQwTKaPqBBGzj0GHx5M3RXM4pdVxufz
 +Oe7elWhnumNOLu5t2ZRdV+rKwGJyV+c/Mcer/x0NtNxuQEi/KY0U8J61xrokN4rxG
 vX7ngwvIF8fve5Q0m3nz+f/KM5BygxZrArVP7SjA=
Authentication-Results: smtp14.mail.yandex.net; dkim=pass header.i=@yandex.ru
Message-ID: <53213E92.9010506@HIDDEN>
Date: Thu, 13 Mar 2014 09:13:54 +0400
From: Dmitry Antipov <dmantipov@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:24.0) Gecko/20100101 Thunderbird/24.3.0
MIME-Version: 1.0
To: jay.p.belanger@HIDDEN, Florian Beck <fb@HIDDEN>
Subject: Re: bug#16999: calc crashes when computation limit is increased
References: <5320A7D9.3000802@HIDDEN> <87vbvjca0w.fsf@HIDDEN>
In-Reply-To: <87vbvjca0w.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 16999
Cc: 16999 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

On 03/13/2014 02:44 AM, Jay Belanger wrote:

> This seems to be an Emacs problem, rather than a problem specific to Calc.
> Typing M doubles the sizes of `max-lisp-eval-depth' and
> `max-specpdl-size'.  Having  `max-lisp-eval-depth' equal to 64000 by
> itself doesn't seem to cause problems, but having `max-lisp-eval-depth'
> equal to 64000 and `max-specpdl-size' equal to 83200 does cause Emacs to
> crash on an infinite loop; evaluating:
>
>    (setq max-specpdl-size 83200
>          max-lisp-eval-depth 64000)
>
>    (defun f ()
>       (f))
>
>    (f)
>
> will crash Emacs.

This is C stack overflow (try to attach gdb and do 'bt' on crash). On
*NIX system, 'ulimit -s' shows your current limit.

Perhaps there should be a kind of protection against this. For example,
eval_sub can check current stack depth against getrlimit (RLIMIT_STACK,...).

Dmitry





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.

Message received at 16999 <at> debbugs.gnu.org:


Received: (at 16999) by debbugs.gnu.org; 12 Mar 2014 22:44:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 12 18:44:32 2014
Received: from localhost ([127.0.0.1]:35032 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WNrt1-0007sA-Rz
	for submit <at> debbugs.gnu.org; Wed, 12 Mar 2014 18:44:32 -0400
Received: from mail-oa0-f54.google.com ([209.85.219.54]:33793)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <jay.p.belanger@HIDDEN>) id 1WNrsx-0007ry-Jg
 for 16999 <at> debbugs.gnu.org; Wed, 12 Mar 2014 18:44:28 -0400
Received: by mail-oa0-f54.google.com with SMTP id n16so215282oag.27
 for <16999 <at> debbugs.gnu.org>; Wed, 12 Mar 2014 15:44:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=from:to:cc:subject:references:reply-to:cc:date:message-id
 :user-agent:mime-version:content-type;
 bh=p2occeeJt5skxOws9jXVvALlO2+whBI9T6PSx8uABkw=;
 b=ODwNZXnz7B6u1UpjUaZqAywiWy8k0zOsDm/FnrVjjglAzHcSl2391nCiRfpEr0vdoK
 BzAqnTQVy26NcliHx24GLkWiYewNEfqndQAHEfOKimzM1L3FwY5W6iFfsZYJrl6vue28
 MojCYravtIuG+Hx3BbYOo3Uhme9SpBpEeqESr7hA96BVu1+hqGcT8I5vIDpPh3Zkmhbv
 8VHcTwTwk5pZeTN33lkrye9MHko8PHOsyMroQnt0ebfjh8f4/bk8IRzXb//PhE3ERKtU
 P35Hnt/lr/SNjLZTayttt67vZbjWYEsQ2YjOVuCTn7SlSlk3I+V68eEJjxbb7I+7Ea8B
 WAQA==
X-Received: by 10.60.15.38 with SMTP id u6mr103733oec.26.1394664266777;
 Wed, 12 Mar 2014 15:44:26 -0700 (PDT)
Received: from belanger-home (184-155-87-143.cpe.cableone.net.
 [184.155.87.143])
 by mx.google.com with ESMTPSA id te6sm1439029oec.2.2014.03.12.15.44.19
 for <multiple recipients>
 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
 Wed, 12 Mar 2014 15:44:26 -0700 (PDT)
From: Jay Belanger <jay.p.belanger@HIDDEN>
To: Florian Beck <fb@HIDDEN>
Subject: Re: bug#16999: calc crashes when computation limit is increased
References: <5320A7D9.3000802@HIDDEN>
Date: Wed, 12 Mar 2014 17:44:15 -0500
Message-ID: <87vbvjca0w.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 16999
Cc: jay.p.belanger@HIDDEN, 16999 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: jay.p.belanger@HIDDEN
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)


> M-x calc
> 2n
> 0
> kc
>
> I.e. try to calculate the binomial coefficient of (-2 0).

This causes Calc to enter an infinite loop.  It needs to be fixed, but
the problem has been around for a while so it probably needs to wait
until after the release.

> Computation got stuck or ran too long.  Type `M' to increase the limit
>
> So do
>
> M
> kc
>
> and repeat a couple of times.
>
> Once `max-lisp-eval-depth' hits 64000 emacs crashes.

This seems to be an Emacs problem, rather than a problem specific to Calc.
Typing M doubles the sizes of `max-lisp-eval-depth' and
`max-specpdl-size'.  Having  `max-lisp-eval-depth' equal to 64000 by
itself doesn't seem to cause problems, but having `max-lisp-eval-depth'
equal to 64000 and `max-specpdl-size' equal to 83200 does cause Emacs to
crash on an infinite loop; evaluating:

  (setq max-specpdl-size 83200
        max-lisp-eval-depth 64000)

  (defun f ()
     (f))

  (f)

will crash Emacs.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 12 Mar 2014 18:55:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 12 14:55:28 2014
Received: from localhost ([127.0.0.1]:34929 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1WNoJL-0000Ro-By
	for submit <at> debbugs.gnu.org; Wed, 12 Mar 2014 14:55:28 -0400
Received: from eggs.gnu.org ([208.118.235.92]:60160)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <fb@HIDDEN>) id 1WNoJH-0000Re-VD
 for submit <at> debbugs.gnu.org; Wed, 12 Mar 2014 14:55:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <fb@HIDDEN>) id 1WNoJC-0007Wt-IL
 for submit <at> debbugs.gnu.org; Wed, 12 Mar 2014 14:55:23 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:42677)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <fb@HIDDEN>) id 1WNoJC-0007Wk-F7
 for submit <at> debbugs.gnu.org; Wed, 12 Mar 2014 14:55:18 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33570)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <fb@HIDDEN>) id 1WNoJ7-00081N-ER
 for bug-gnu-emacs@HIDDEN; Wed, 12 Mar 2014 14:55:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <fb@HIDDEN>) id 1WNoJ1-0007SL-Ed
 for bug-gnu-emacs@HIDDEN; Wed, 12 Mar 2014 14:55:13 -0400
Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::5]:60638)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <fb@HIDDEN>) id 1WNoJ1-0007Nl-2B
 for bug-gnu-emacs@HIDDEN; Wed, 12 Mar 2014 14:55:07 -0400
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1394650505; l=776;
 s=domk; d=streitblatt.de;
 h=Content-Transfer-Encoding:Content-Type:Subject:To:MIME-Version:From:
 Date:X-RZG-CLASS-ID:X-RZG-AUTH;
 bh=Trkgg5kZR1HM8OJ1ZZwccO5T4Yk=;
 b=i8mt5NXiV8I8wPFosHfRkbt1ZGmDJS66tY/RcZGTOsxYpUB6t2marZyC0BPytd1R2d4
 dc9czwJn7GFsfOspbSotdCo7PBiiK2NHiprJ7jfY0nQ/eiWEwrHvYjvNyU0TpRX55DNLH
 f50LLcUwaBsbk9WS3R76jQmrlnNaU6ezww4=
X-RZG-AUTH: :KmALZ0mpdbGonPxw7gDkop508XQjelhLxGYn4B74/iddlkME3ssvHN/NX3uKqg+oBr3QLb7VhqJ7
X-RZG-CLASS-ID: mo00
Received: from [109.43.140.244] (ip-109-43-140-244.web.vodafone.de
 [109.43.140.244]) by smtp.strato.de (RZmta 32.27 DYNA|AUTH)
 with ESMTPSA id j04b4cq2CIUpuCF
 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
 (Client did not present a certificate) for <bug-gnu-emacs@HIDDEN>;
 Wed, 12 Mar 2014 19:30:51 +0100 (CET)
Message-ID: <5320A7D9.3000802@HIDDEN>
Date: Wed, 12 Mar 2014 19:30:49 +0100
From: Florian Beck <fb@HIDDEN>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
 rv:24.0) Gecko/20100101 Thunderbird/24.3.0
MIME-Version: 1.0
To: bug-gnu-emacs@HIDDEN
Subject: calc crashes when computation limit is increased
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

M-x calc
2n
0
kc

I.e. try to calculate the binomial coefficient of (-2 0). This doesn't
work and calc suggests you give it more time:

Computation got stuck or ran too long.  Type `M' to increase the limit

So do

M
kc

and repeat a couple of times.

Once `max-lisp-eval-depth' hits 64000 emacs crashes.

I can send a backtrace if necessary.


In GNU Emacs 24.3.50.46 (x86_64-unknown-linux-gnu, GTK+ Version 3.8.6)
  of 2014-03-12 on sophokles
Windowing system distributor `The X.Org Foundation', version 11.0.11405000
System Description:	Ubuntu 13.10

Configured using:
  `configure CC=gcc 'CFLAGS=-march=native -mtune=native -msse -msse2
  -msse3 -mmmx -O2 -pipe -g3 -fno-omit-frame-pointer -fno-crossjumping'
  LDFLAGS=-O2'


-- 
Florian Beck




Acknowledgement sent to Florian Beck <fb@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#16999; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.