From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 12 14:55:28 2014 Received: (at submit) by debbugs.gnu.org; 12 Mar 2014 18:55:28 +0000 Received: from localhost ([127.0.0.1]:34929 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WNoJL-0000Ro-By for submit@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 ) id 1WNoJH-0000Re-VD for submit@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 ) id 1WNoJC-0007Wt-IL for submit@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 ) id 1WNoJC-0007Wk-F7 for submit@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 ) id 1WNoJ7-00081N-ER for bug-gnu-emacs@gnu.org; Wed, 12 Mar 2014 14:55:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNoJ1-0007SL-Ed for bug-gnu-emacs@gnu.org; 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 ) id 1WNoJ1-0007Nl-2B for bug-gnu-emacs@gnu.org; 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 ; Wed, 12 Mar 2014 19:30:51 +0100 (CET) Message-ID: <5320A7D9.3000802@miszellen.de> Date: Wed, 12 Mar 2014 19:30:49 +0100 From: Florian Beck 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@gnu.org 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@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 12 18:44:32 2014 Received: (at 16999) by debbugs.gnu.org; 12 Mar 2014 22:44:32 +0000 Received: from localhost ([127.0.0.1]:35032 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WNrt1-0007sA-Rz for submit@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 ) id 1WNrsx-0007ry-Jg for 16999@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@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 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 12 Mar 2014 15:44:26 -0700 (PDT) From: Jay Belanger To: Florian Beck Subject: Re: bug#16999: calc crashes when computation limit is increased References: <5320A7D9.3000802@miszellen.de> Date: Wed, 12 Mar 2014 17:44:15 -0500 Message-ID: <87vbvjca0w.fsf@gmail.com> 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@gmail.com, 16999@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: jay.p.belanger@gmail.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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. From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 13 01:14:00 2014 Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 05:14:00 +0000 Received: from localhost ([127.0.0.1]:35227 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WNxxw-0004e8-93 for submit@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 ) id 1WNxxt-0004dt-8V for 16999@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@yandex.ru> Date: Thu, 13 Mar 2014 09:13:54 +0400 From: Dmitry Antipov 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@gmail.com, Florian Beck Subject: Re: bug#16999: calc crashes when computation limit is increased References: <5320A7D9.3000802@miszellen.de> <87vbvjca0w.fsf@gmail.com> In-Reply-To: <87vbvjca0w.fsf@gmail.com> 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@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 13 05:11:57 2014 Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 09:11:57 +0000 Received: from localhost ([127.0.0.1]:35320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WO1gC-0003uk-FV for submit@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 ) id 1WO1g9-0003uW-65 for 16999@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@yandex.ru> Date: Thu, 13 Mar 2014 13:11:50 +0400 From: Dmitry Antipov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: 16999@debbugs.gnu.org Subject: Re: bug#16999: calc crashes when computation limit is increased References: <5320A7D9.3000802@miszellen.de> <87vbvjca0w.fsf@gmail.com> <53213E92.9010506@yandex.ru> In-Reply-To: <53213E92.9010506@yandex.ru> Content-Type: multipart/mixed; boundary="------------030105050506050607080105" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 16999 Cc: Eli Zaretskii , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 +#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-- From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 13 09:42:28 2014 Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 13:42:29 +0000 Received: from localhost ([127.0.0.1]:35505 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WO5tz-0005Ur-JE for submit@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 ) id 1WO5tt-0005Uf-KJ for 16999@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 To: Dmitry Antipov Subject: Re: bug#16999: calc crashes when computation limit is increased Message-ID: References: <5320A7D9.3000802@miszellen.de> <87vbvjca0w.fsf@gmail.com> <53213E92.9010506@yandex.ru> Date: Thu, 13 Mar 2014 09:42:20 -0400 In-Reply-To: <53213E92.9010506@yandex.ru> (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@gmail.com, 16999@debbugs.gnu.org, Florian Beck X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 13 10:06:15 2014 Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 14:06:15 +0000 Received: from localhost ([127.0.0.1]:35965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WO6H0-0006IS-I2 for submit@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 ) id 1WO6Gw-0006IG-Nt for 16999@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@miszellen.de> Date: Thu, 13 Mar 2014 15:06:06 +0100 From: Florian Beck 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 , 16999@debbugs.gnu.org Subject: Re: bug#16999: calc crashes when computation limit is increased References: <5320A7D9.3000802@miszellen.de> <87vbvjca0w.fsf@gmail.com> <53213E92.9010506@yandex.ru> <53217656.7080608@yandex.ru> In-Reply-To: <53217656.7080608@yandex.ru> 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@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 13 10:12:08 2014 Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 14:12:08 +0000 Received: from localhost ([127.0.0.1]:35969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WO6Mi-0006TP-1i for submit@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 ) id 1WO6Mg-0006TH-9u for 16999@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@miszellen.de> Date: Thu, 13 Mar 2014 15:12:02 +0100 From: Florian Beck 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 , Dmitry Antipov Subject: Re: bug#16999: calc crashes when computation limit is increased References: <5320A7D9.3000802@miszellen.de> <87vbvjca0w.fsf@gmail.com> <53213E92.9010506@yandex.ru> In-Reply-To: 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@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 13 10:30:47 2014 Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 14:30:47 +0000 Received: from localhost ([127.0.0.1]:35996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WO6ek-00074r-Jp for submit@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 ) id 1WO6eg-00074c-QW for 16999@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@yandex.ru> Date: Thu, 13 Mar 2014 18:30:40 +0400 From: Dmitry Antipov 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 Subject: Re: bug#16999: calc crashes when computation limit is increased References: <5320A7D9.3000802@miszellen.de> <87vbvjca0w.fsf@gmail.com> <53213E92.9010506@yandex.ru> <53217656.7080608@yandex.ru> <5321BB4E.4080009@miszellen.de> In-Reply-To: <5321BB4E.4080009@miszellen.de> Content-Type: multipart/mixed; boundary="------------090508040303060105010903" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 16999 Cc: 16999@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 +#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-- From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 13 12:57:03 2014 Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 16:57:03 +0000 Received: from localhost ([127.0.0.1]:36091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WO8wJ-0003Jn-3H for submit@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 ) id 1WO8wG-0003JD-6G for 16999@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@a-mtaout22.012.net.il> for 16999@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@a-mtaout22.012.net.il>; Thu, 13 Mar 2014 18:56:58 +0200 (IST) Date: Thu, 13 Mar 2014 18:56:53 +0200 From: Eli Zaretskii Subject: Re: bug#16999: calc crashes when computation limit is increased In-reply-to: <53217656.7080608@yandex.ru> X-012-Sender: halo1@inter.net.il To: Dmitry Antipov Message-id: <834n32niju.fsf@gnu.org> References: <5320A7D9.3000802@miszellen.de> <87vbvjca0w.fsf@gmail.com> <53213E92.9010506@yandex.ru> <53217656.7080608@yandex.ru> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 16999 Cc: eggert@cs.ucla.edu, 16999@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > Date: Thu, 13 Mar 2014 13:11:50 +0400 > From: Dmitry Antipov > CC: Paul Eggert , Eli Zaretskii > > 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. From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 13 17:16:02 2014 Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 21:16:02 +0000 Received: from localhost ([127.0.0.1]:36203 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WOCyv-00034w-SF for submit@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 ) id 1WOCyt-00034g-TF for 16999@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@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 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 13 Mar 2014 14:15:58 -0700 (PDT) From: Jay Belanger To: Florian Beck Subject: Re: bug#16999: calc crashes when computation limit is increased References: <5320A7D9.3000802@miszellen.de> <87vbvjca0w.fsf@gmail.com> <53213E92.9010506@yandex.ru> <5321BCB2.8080605@miszellen.de> Date: Thu, 13 Mar 2014 16:15:56 -0500 In-Reply-To: <5321BCB2.8080605@miszellen.de> (Florian Beck's message of "Thu, 13 Mar 2014 15:12:02 +0100") Message-ID: <87r465dckz.fsf@gmail.com> 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@gmail.com, Dmitry Antipov , 16999@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: jay.p.belanger@gmail.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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. From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 13 18:10:44 2014 Received: (at 16999) by debbugs.gnu.org; 13 Mar 2014 22:10:44 +0000 Received: from localhost ([127.0.0.1]:36210 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WODpr-0004k7-9B for submit@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 ) id 1WODpo-0004jt-RZ for 16999@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 To: Florian Beck Subject: Re: bug#16999: calc crashes when computation limit is increased Message-ID: References: <5320A7D9.3000802@miszellen.de> <87vbvjca0w.fsf@gmail.com> <53213E92.9010506@yandex.ru> <5321BCB2.8080605@miszellen.de> Date: Thu, 13 Mar 2014 18:10:05 -0400 In-Reply-To: <5321BCB2.8080605@miszellen.de> (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@iro.umontreal.ca X-Spam-Status: No X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 16999 Cc: Dmitry Antipov , 16999@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) > Maybe calc shouldn't bump them too high, then. Indeed, it shouldn't. Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 09 08:19:31 2020 Received: (at 16999) by debbugs.gnu.org; 9 Sep 2020 12:19:31 +0000 Received: from localhost ([127.0.0.1]:57650 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFz4V-0001Kv-ED for submit@debbugs.gnu.org; Wed, 09 Sep 2020 08:19:31 -0400 Received: from quimby.gnus.org ([95.216.78.240]:53434) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFz4R-0001Kb-KX for 16999@debbugs.gnu.org; Wed, 09 Sep 2020 08:19:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Rz0GklSbRN60waNEVovsERj6MIr28hSH8Vmxs59EN0g=; b=cc8ceVOtR2nzZtUp2Zf2zAXv93 5t5bmuEWBwEiY0pX13o8p7LbvHyeZ8/FDj53aCUmFgkVCpnoqs95tPouOPGlqKVPyC7V9VE8GhOV6 Q/E195dmuweWTVI1sKjj2MBD0aoNEZRutEQ6p2IWb5huI2pBXHZsTAzuCURA/jtdXA6I=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kFz4J-0002PQ-8K; Wed, 09 Sep 2020 14:19:21 +0200 From: Lars Ingebrigtsen To: Florian Beck Subject: Re: bug#16999: calc crashes when computation limit is increased References: <5320A7D9.3000802@miszellen.de> X-Now-Playing: Jay Glass Dubs's _Epitaph_: "Evil Empire" Date: Wed, 09 Sep 2020 14:19:17 +0200 In-Reply-To: <5320A7D9.3000802@miszellen.de> (Florian Beck's message of "Wed, 12 Mar 2014 19:30:49 +0100") Message-ID: <87r1rbb0sa.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Florian Beck writes: > 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' [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16999 Cc: 16999@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Florian Beck writes: > 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. It seems like this problem has been fixed by the general C stack protection. Trying this in Emacs 28 I just get: Re-entering top level after C stack overflow So I'm closing this bug report. If this is still a problem, please respond to the debbugs address and we'll reopen. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 09 08:19:37 2020 Received: (at control) by debbugs.gnu.org; 9 Sep 2020 12:19:38 +0000 Received: from localhost ([127.0.0.1]:57653 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFz4b-0001LE-MW for submit@debbugs.gnu.org; Wed, 09 Sep 2020 08:19:37 -0400 Received: from quimby.gnus.org ([95.216.78.240]:53446) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kFz4Z-0001Ko-TH for control@debbugs.gnu.org; Wed, 09 Sep 2020 08:19:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DKRLrHqcI+aYri0++qtVFjr5B85VbPaO1qL9OdNWdGs=; b=PkNQyB/hyOvQG1PdG/JpXIF/Qv 3WGpqPZNtmGt+Jq63vruJ5iSJYkSw/+BlYYlWLYhpcKjs0ou/12C102hnuxeIb/eekc50fAuoOsdW xhvlgsQGL0eAmoTEhZ+7hx74AHTsKrUAg+PIFI5PhpWfodup5LlYtsFhFNHzx/qkY4Hc=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kFz4S-0002Pa-4n for control@debbugs.gnu.org; Wed, 09 Sep 2020 14:19:30 +0200 Date: Wed, 09 Sep 2020 14:19:26 +0200 Message-Id: <87pn6vb0s1.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #16999 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 16999 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) close 16999 quit From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 10 12:02:53 2020 Received: (at 16999) by debbugs.gnu.org; 10 Sep 2020 16:02:53 +0000 Received: from localhost ([127.0.0.1]:40990 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kGP2D-0007P7-5o for submit@debbugs.gnu.org; Thu, 10 Sep 2020 12:02:53 -0400 Received: from mail1443c50.megamailservers.eu ([91.136.14.43]:38596 helo=mail264c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kGP2A-0007Oh-6L; Thu, 10 Sep 2020 12:02:51 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1599753763; bh=CKxhK9MTuIgPbidN3FHK3XLQPCkow+EKBIBwDKnSOlI=; h=From:Date:Subject:Cc:To:From; b=n5SrzSu4cQ9oowIL1KnNZrgQeRAcQo6ZUiUrPQ3R3G9bAes/W3vKvcweXwSWUqqpl /9Ofcoaka9AiPl5vb6jIVVU1VFWIYLDSZ+vpVbK1WjwJsg/A13y6HZWGmmUTweDk59 DSNKpHJM9lVVy7kvIwLeY+/8d7oFtnwKUGgPztcY= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail264c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08AG2eCj030081; Thu, 10 Sep 2020 16:02:42 +0000 From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Date: Thu, 10 Sep 2020 18:02:39 +0200 Subject: Re: bug#16999: calc crashes when computation limit is increased To: Lars Ingebrigtsen Message-Id: <64145024-4251-4F81-9345-4E2E064FBC1C@acm.org> X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F1E.5F5A4E23.0095, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=PPNxBsiC c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=AlRptKtCDsQNCIiSNEkA:9 a=CjuIK1q_8ugA:10 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: reopen 16999 make it so While the C-level crash has been fixed, the Calc bug (infinite loop) has not. Whether to signal a domain error for (-2 choose 0) or return the conventional value by extension is a matter of taste; I think the latter would be more useful. In fact, I see no reason not to extend t [...] Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 16999 Cc: Florian Beck , 16999@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) reopen 16999 make it so While the C-level crash has been fixed, the Calc bug (infinite loop) has = not. Whether to signal a domain error for (-2 choose 0) or return the = conventional value by extension is a matter of taste; I think the latter = would be more useful. In fact, I see no reason not to extend the = function to all integral arguments, but would of course value any = half-supported opinion on the matter. Let me attempt a patch, and please forgive my reopening the bug. From unknown Fri Aug 15 20:29:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: Did not alter fixed versions and reopened. Date: Thu, 10 Sep 2020 16:03:02 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # Did not alter fixed versions and reopened. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 11 06:30:02 2020 Received: (at 16999) by debbugs.gnu.org; 11 Sep 2020 10:30:02 +0000 Received: from localhost ([127.0.0.1]:42477 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kGgJd-000571-SG for submit@debbugs.gnu.org; Fri, 11 Sep 2020 06:30:02 -0400 Received: from mail83c50.megamailservers.eu ([91.136.10.93]:47522 helo=mail18c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kGgJb-00056l-DA; Fri, 11 Sep 2020 06:30:00 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1599820197; bh=e81Ocsswo3sVnSVIL/vI1fogf2nBEIoro0U9986tjf4=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=cXyGsJ8vA7r316LTqbuqS+OOsW6kN48+5xrnV+2xhcaLpMVS9BLnYmcLVj1U1pfPf 6VBFgOLBbAMqLxOe/gzOftVQzkqQf6/XiqezO51nxD/EJlDprgfK1oCgfMWiH6As26 fKkkqhkLE4eyPY2V8PvnxEd4nA/LmpXLkJxZvkVw= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail18c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08BATtcu029452; Fri, 11 Sep 2020 10:29:56 +0000 Content-Type: multipart/mixed; boundary="Apple-Mail=_19A3E6C3-C92C-4261-8903-E278D04420C4" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Subject: Re: bug#16999: calc crashes when computation limit is increased From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: <64145024-4251-4F81-9345-4E2E064FBC1C@acm.org> Date: Fri, 11 Sep 2020 12:29:54 +0200 Message-Id: <7CB65B96-318A-4641-A4F4-FBD4CB43EC22@acm.org> References: <64145024-4251-4F81-9345-4E2E064FBC1C@acm.org> To: Lars Ingebrigtsen X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F29.5F5B51A5.004E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=K8Zc4BeI c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=N54-gffFAAAA:8 a=EWPDJS0nAAAA:8 a=D_ldmLNfM3nHP4qRlzcA:9 a=QEXdDO2ut3YA:10 a=gczXvjW0MzpGF8ZVD5kA:9 a=B2y7HmGcmWMA:10 a=6l0D2HzqY3Epnrm8mE3f:22 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 10 sep. 2020 kl. 18.02 skrev Mattias EngdegĂ„rd : > Let me attempt a patch, and please forgive my reopening the bug. Here is that patch. Sadly mail to Florian Beck's address bounced but perhaps someone else will see the proposal and subject it to scrutiny. In short: Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 16999 Cc: 16999@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --Apple-Mail=_19A3E6C3-C92C-4261-8903-E278D04420C4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 10 sep. 2020 kl. 18.02 skrev Mattias Engdeg=C3=A5rd : > Let me attempt a patch, and please forgive my reopening the bug. Here is that patch. Sadly mail to Florian Beck's address bounced but = perhaps someone else will see the proposal and subject it to scrutiny. = In short: 1. A sign mistake in the original code caused the infinite recursion. = Fixed. 2. Some parts of the computation used tail recursion, which limited = their applicability in elisp. Changed to use an imperative loop (alas). 3. The binomial coefficients have now been extended for all integral = arguments, using definitions from [1]; see also [2] and [3]. [1] M. J. Kronenburg; The Binomial Coefficient for Negative Arguments; = https://arxiv.org/abs/1105.3689 [2] D. Loeb, E. Damiani and O. D=E2=80=99Antona; Getting Results with = Negative Thinking; https://arxiv.org/abs/math/9502214 [3] David Fowler; The Binomial Coefficient Function; The American = Mathematical Monthly, Vol. 103, No. 1 (Jan., 1996), pp. 1-17 --Apple-Mail=_19A3E6C3-C92C-4261-8903-E278D04420C4 Content-Disposition: attachment; filename=0001-Calc-fix-binomial-coefficients-for-negative-argument.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Calc-fix-binomial-coefficients-for-negative-argument.patch" Content-Transfer-Encoding: quoted-printable =46rom=20c451146726adfacdec69247c3da6dc4ebacd1b97=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Fri,=2011=20Sep=202020=2011:43:15=20+0200=0A= Subject:=20[PATCH]=20Calc:=20fix=20binomial=20coefficients=20for=20= negative=20arguments=0A=20(bug#16999)=0AMIME-Version:=201.0=0A= Content-Type:=20text/plain;=20charset=3DUTF-8=0A= Content-Transfer-Encoding:=208bit=0A=0AFor=20some=20values=20outside=20= integers=200=E2=89=A4k=E2=89=A4n,=20(n=20choose=20k)=20gave=20wrong=0A= results,=20entered=20infinite=20recursion=20or=20used=20unreasonably=20= amounts=20of=0Astack=20space.=20=20This=20change=20fixes=20that=20and=20= extends=20the=20function=20to=20all=0Ainteger=20arguments=20using=20the=20= definitions=20from=20M.=20J.=20Kronenburg=0A= (https://arxiv.org/abs/1105.3689).=0A=0A*=20lisp/calc/calc-comb.el=20= (calcFunc-choose):=0AFix=20sign=20error=20to=20prevent=20infinite=20= recursion=20and=20extend=20function=20to=0Ahandle=20all=20integer=20= arguments.=0A(math-choose-iter,=20math-choose-float-iter):=20Rewrite=20= in=20iterative=20form;=0Ano=20TCO=20in=20elisp=20yet.=0A*=20= test/lisp/calc/calc-tests.el=20(calc-tests--fac,=20calc-tests--choose)=0A= (calc-tests--check-choose,=20calc-tests--explain-choose)=0A= (calc-tests--calc-to-number):=20New=20helper=20functions.=0A= (calc-choose):=20New=20test.=0A---=0A=20lisp/calc/calc-comb.el=20=20=20=20= =20=20=20|=2042=20+++++++++++++++-------=0A=20= test/lisp/calc/calc-tests.el=20|=2067=20= ++++++++++++++++++++++++++++++++++++=0A=202=20files=20changed,=2096=20= insertions(+),=2013=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/calc/calc-comb.el=20b/lisp/calc/calc-comb.el=0Aindex=20= c5d4d0837e..ce676d17a9=20100644=0A---=20a/lisp/calc/calc-comb.el=0A+++=20= b/lisp/calc/calc-comb.el=0A@@=20-445,12=20+445,25=20@@=20calcFunc-choose=0A= =20=09=20=20=20(math-div=20(calcFunc-fact=20(math-float=20n))=0A=20=09=09= =20=20=20=20=20(math-mul=20(calcFunc-fact=20m)=0A=20=09=09=09=20=20=20=20= =20=20=20(calcFunc-fact=20(math-sub=20n=20m))))))=0A-=09((math-negp=20m)=20= 0)=0A-=09((math-negp=20n)=0A-=09=20(let=20((val=20(calcFunc-choose=20= (math-add=20(math-add=20n=20m)=20-1)=20m)))=0A+=20=20=20=20=20=20=20=20= ;;=20For=20the=20extension=20to=20negative=20integer=20arguments=20we=20= follow=0A+=20=20=20=20=20=20=20=20;;=20M.=20J.=20Kronenburg,=20The=20= Binomial=20Coefficient=20for=20Negative=20Arguments,=0A+=20=20=20=20=20=20= =20=20;;=20arXiv:1105.3689v2=0A+=20=20=20=20=20=20=20=20((and=20= (math-negp=20n)=20(not=20(math-negp=20m)))=0A+=20=20=20=20=20=20=20=20=20= ;;=20n<0=E2=89=A4m:=20(n=20choose=20m)=20=3D=20(-1)^m=20(-n+m-1=20choose=20= m)=0A+=09=20(let=20((val=20(calcFunc-choose=20(math-add=20(math-sub=20m=20= n)=20-1)=20m)))=0A=20=09=20=20=20(if=20(math-evenp=20(math-trunc=20m))=0A= =20=09=20=20=20=20=20=20=20val=0A=20=09=20=20=20=20=20(math-neg=20= val))))=0A+=20=20=20=20=20=20=20=20((and=20(math-negp=20n)=20= (math-num-integerp=20n))=0A+=20=20=20=20=20=20=20=20=20(if=20(math-lessp=20= n=20m)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=200=0A+=20=20=20=20=20=20=20= =20=20=20=20;;=20m=E2=89=A4n<0:=20(n=20choose=20m)=20=3D=20(-1)^(n-m)=20= (-m-1=20choose=20n-m)=0A+=20=20=20=20=20=20=20=20=20=20=20(let=20((val=20= (calcFunc-choose=20(math-sub=20(math-neg=20m)=201)=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(math-sub=20n=20m))))=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20(if=20(math-evenp=20(math-sub=20n=20m))=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20val=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(math-neg=20val)))))=0A+=09((math-negp=20m)=200)=0A=20=09= ((and=20(math-num-integerp=20n)=0A=20=09=20=20=20=20=20=20(Math-lessp=20= n=20m))=0A=20=09=200)=0A@@=20-467,20=20+480,23=20@@=20calcFunc-choose=0A=20= =09=20=20=20=20=20=20=20(math-choose-float-iter=20tm=20n=201=201)))))))=0A= =20=0A=20(defun=20math-choose-iter=20(m=20n=20i=20c)=0A-=20=20(if=20(and=20= (=3D=20(%=20i=205)=201)=20(>=20i=205))=0A+=20=20(while=20(<=3D=20i=20m)=0A= +=20=20=20=20(when=20(and=20(=3D=20(%=20i=205)=201)=20(>=20i=205))=0A=20=20= =20=20=20=20=20(math-working=20(format=20"choose(%d)"=20(1-=20i))=20c))=0A= -=20=20(if=20(<=3D=20i=20m)=0A-=20=20=20=20=20=20(math-choose-iter=20m=20= (1-=20n)=20(1+=20i)=0A-=09=09=09(math-quotient=20(math-mul=20c=20n)=20= i))=0A-=20=20=20=20c))=0A+=20=20=20=20(setq=20c=20(math-quotient=20= (math-mul=20c=20n)=20i))=0A+=20=20=20=20(setq=20n=20(1-=20n))=0A+=20=20=20= =20(setq=20i=20(1+=20i)))=0A+=20=20c)=0A=20=0A=20(defun=20= math-choose-float-iter=20(count=20n=20i=20c)=0A-=20=20(if=20(=3D=20(%=20= i=205)=201)=0A+=20=20(while=20(>=20count=200)=0A+=20=20=20=20(when=20(=3D=20= (%=20i=205)=201)=0A=20=20=20=20=20=20=20(math-working=20(format=20= "choose(%d)"=20(1-=20i))=20c))=0A-=20=20(if=20(>=20count=200)=0A-=20=20=20= =20=20=20(math-choose-float-iter=20(1-=20count)=20(math-sub=20n=201)=20= (1+=20i)=0A-=09=09=09=20=20=20=20=20=20(math-div=20(math-mul=20c=20n)=20= i))=0A-=20=20=20=20c))=0A+=20=20=20=20(setq=20c=20(math-div=20(math-mul=20= c=20n)=20i))=0A+=20=20=20=20(setq=20n=20(math-sub=20n=201))=0A+=20=20=20=20= (setq=20i=20(1+=20i))=0A+=20=20=20=20(setq=20count=20(1-=20count)))=0A+=20= =20c)=0A=20=0A=20=0A=20;;;=20Stirling=20numbers.=0Adiff=20--git=20= a/test/lisp/calc/calc-tests.el=20b/test/lisp/calc/calc-tests.el=0Aindex=20= c8cb97a8bc..5030a55472=20100644=0A---=20a/test/lisp/calc/calc-tests.el=0A= +++=20b/test/lisp/calc/calc-tests.el=0A@@=20-397,6=20+397,73=20@@=20= calc-sum-gcd=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(var=20n=20var-n)=20-1=201))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=208)))=0A=20=0A+(defun=20calc-tests--fac=20(n)=0A+=20=20= (apply=20#'*=20(number-sequence=201=20n)))=0A+=0A+(defun=20= calc-tests--choose=20(n=20k)=0A+=20=20"N=20choose=20K,=20reference=20= implementation."=0A+=20=20(cond=0A+=20=20=20((and=20(integerp=20n)=20= (integerp=20k))=0A+=20=20=20=20(if=20(<=3D=200=20n)=0A+=20=20=20=20=20=20= =20=20(if=20(<=3D=200=20k=20n)=0A+=20=20=20=20=20=20=20=20=20=20=20=20(/=20= (calc-tests--fac=20n)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(*=20= (calc-tests--fac=20k)=20(calc-tests--fac=20(-=20n=20k))))=0A+=20=20=20=20= =20=20=20=20=20=200)=20=20=20=20;=200=E2=89=A4n=20%S,=20expected=20%S"=20n=20k=20got=20= expected)))=0A+=0A+(put=20'calc-tests--check-choose=20'ert-explainer=20= 'calc-tests--explain-choose)=0A+=0A+(defun=20calc-tests--calc-to-number=20= (x)=0A+=20=20"Convert=20a=20Calc=20object=20to=20a=20Lisp=20number."=0A+=20= =20(pcase=20x=0A+=20=20=20=20((pred=20numberp)=20x)=0A+=20=20=20=20= (`(frac=20,p=20,q)=20(/=20(float=20p)=20q))=0A+=20=20=20=20(`(float=20,m=20= ,e)=20(*=20m=20(expt=2010=20e)))=0A+=20=20=20=20(_=20(error=20"calc=20= object=20not=20converted:=20%S"=20x))))=0A+=0A+(ert-deftest=20= calc-choose=20()=0A+=20=20"Test=20computation=20of=20binomial=20= coefficients=20(bug#16999)."=0A+=20=20;;=20Integral=20arguments=0A+=20=20= (dolist=20(n=20(number-sequence=20-6=206))=0A+=20=20=20=20(dolist=20(k=20= (number-sequence=20-6=206))=0A+=20=20=20=20=20=20(should=20= (calc-tests--check-choose=20n=20k))))=0A+=0A+=20=20;;=20Fractional=20n,=20= natural=20k=0A+=20=20(should=20(equal=20(calc-tests--calc-to-number=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(calcFunc-choose=20= '(frac=2015=202)=203))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(calc-tests--choose=207.5=203)))=0A+=0A+=20=20(should=20(equal=20= (calc-tests--calc-to-number=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(calcFunc-choose=20'(frac=201=202)=202))=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(calc-tests--choose=200.5=202)))=0A+=0A= +=20=20(should=20(equal=20(calc-tests--calc-to-number=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(calcFunc-choose=20'(frac=20-15=202)=20= 3))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (calc-tests--choose=20-7.5=203))))=0A+=0A=20(provide=20'calc-tests)=0A=20= ;;;=20calc-tests.el=20ends=20here=0A=20=0A--=20=0A2.21.1=20(Apple=20= Git-122.3)=0A=0A= --Apple-Mail=_19A3E6C3-C92C-4261-8903-E278D04420C4-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 11 07:54:19 2020 Received: (at 16999) by debbugs.gnu.org; 11 Sep 2020 11:54:19 +0000 Received: from localhost ([127.0.0.1]:42733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kGhdD-0003Do-28 for submit@debbugs.gnu.org; Fri, 11 Sep 2020 07:54:19 -0400 Received: from quimby.gnus.org ([95.216.78.240]:50328) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kGhdA-0003Da-4T for 16999@debbugs.gnu.org; Fri, 11 Sep 2020 07:54:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=NU3CGvfnStGRowrG5yJL7pagiTY73SJuXjLwesPm9FM=; b=A6tknx5e/fLHl7F1d3dnteoWZW Od0v5Ui43AKGEjgOIAd2xt8BfBFNG7lT3vB9GyjpYS7xMgCuYTtEKueZLmkaRMEuR/Xwo7vhJmV4h o7AK3fl9Qu8rMFoSN8CSAXgpoc8fDECFvRxATFEDwCDbS0kJ1cOf/s6txJ7IPywHO/6c=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGhd1-0001fi-74; Fri, 11 Sep 2020 13:54:09 +0200 From: Lars Ingebrigtsen To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= Subject: Re: bug#16999: calc crashes when computation limit is increased References: <64145024-4251-4F81-9345-4E2E064FBC1C@acm.org> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAMFBMVEUaGBomIyQ2MTId HCFaUUwhHiAhHB4ODA42Ih5kSjqRcVeAWTtPMSypjW60nIX///8gj8uoAAAAAWJLR0QPGLoA2QAA AAd0SU1FB+QJCwsqGgVMzPcAAAGKSURBVDjLdZA/T8JAGMbfivwzDFbTwcHBi6MmJP0CSjo5lZDr XIZ2cqiDsjgwkejooDjwAYhonI0Di8QB3KkeH4BEP4PXFo732uMZru3zu+ee9woaUehA3wXtkFhp l8sGzbKsU/5OdmJXj2V4wMFiDxalEYBm2ne8Kge1TMBzAaKEVasjt27YTuTDBa9IQLJS348DcEls TzeoQfksfHuyO9IV0Q2HUqpzxn0XAVKAgsdtp6kbtvAhIITvyvuO4xV0cBFIHjzl3jyNPyGrgv94 9N5RAG1jUBlA5iheUz45/wHVUXvk+hW2FeB2PnlQJeArDIdK8ML6bWXHbP48El/VFcjP2PfH8iOH gMb+uq4K5Fk47qgAPLOBr+qoMDbF5eKXlHqz33tVAo7ZtK3sKL91xXvOxFdE05oSOFtNazYw6PVF RE5MQlFuonH5WAhIiX02VJdvhSMRaMigLRIS2EQdEijdrbkHmlAuR2qsA2sTZi5ai61YQZACCz+W dFQLC4rBEhRbaS3OzIJY/3sEjAf8ow9GAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIwLTA5LTExVDEx OjQyOjI2KzAwOjAwLlEI9gAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMC0wOS0xMVQxMTo0MjoyNisw MDowMF8MsEoAAAAASUVORK5CYII= X-Now-Playing: Melanie de Biasio's _No Deal_: "With Love" Date: Fri, 11 Sep 2020 13:54:05 +0200 In-Reply-To: <64145024-4251-4F81-9345-4E2E064FBC1C@acm.org> ("Mattias =?utf-8?Q?Engdeg=C3=A5rd=22's?= message of "Thu, 10 Sep 2020 18:02:39 +0200") Message-ID: <87r1r8zfz6.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Mattias EngdegĂ„rd writes: > While the C-level crash has been fixed, the Calc bug (infinite loop) has not. Ah, sorry, I thought I had tested that bit too, but I must have done something wrong... Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 16999 Cc: Florian Beck , 16999@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Mattias Engdeg=C3=A5rd writes: > While the C-level crash has been fixed, the Calc bug (infinite loop) has = not. Ah, sorry, I thought I had tested that bit too, but I must have done something wrong... --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 14 05:45:52 2020 Received: (at 16999-done) by debbugs.gnu.org; 14 Sep 2020 09:45:52 +0000 Received: from localhost ([127.0.0.1]:52561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHl3Y-0003Lj-FJ for submit@debbugs.gnu.org; Mon, 14 Sep 2020 05:45:52 -0400 Received: from mail153c50.megamailservers.eu ([91.136.10.163]:54698 helo=mail50c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kHl3T-0003LW-GI for 16999-done@debbugs.gnu.org; Mon, 14 Sep 2020 05:45:51 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1600076744; bh=yyMkxihLlfuWs2KrmQzlUIEGz9N+FDtZ2+SDT66Cc4g=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=o9dVH2l4lHPnLsN0T0WMHpvcvb/SZxM4rk4Z+WnEu1Ab5dF0rs254KcSK0Uga5Ala a1ymTtH/tty1+vIxQEcNOlcqosr2o6UvCu+C4Js7A3cLLAfci0XeJ9nZr82wNoffRY t1iAPB/bOPHW+9o0qvDQv0afI4xwScNQg0uXm2Rw= Feedback-ID: mattiase@acm.or Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail50c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 08E9jgo8004282; Mon, 14 Sep 2020 09:45:44 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.15\)) Subject: Re: bug#16999: calc crashes when computation limit is increased From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= In-Reply-To: <87r1r8zfz6.fsf@gnus.org> Date: Mon, 14 Sep 2020 11:45:42 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <64145024-4251-4F81-9345-4E2E064FBC1C@acm.org> <87r1r8zfz6.fsf@gnus.org> To: Lars Ingebrigtsen X-Mailer: Apple Mail (2.3445.104.15) X-CTCH-RefID: str=0001.0A782F22.5F5F3BC8.0067, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=NoevjPVJ c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=OocQHUDgAAAA:8 a=N7DzwKPofjxEXIncjyQA:9 a=CjuIK1q_8ugA:10 a=xUZTl98r3Qw_uB5NK3jt:22 X-Origin-Country: SE X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 11 sep. 2020 kl. 13.54 skrev Lars Ingebrigtsen : > Ah, sorry, I thought I had tested that bit too, but I must have done > something wrong... Well, you dug up an old bug and turned our attention to it, so in a sense you did bring about the resolution! Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-Debbugs-Envelope-To: 16999-done Cc: 16999-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) 11 sep. 2020 kl. 13.54 skrev Lars Ingebrigtsen : > Ah, sorry, I thought I had tested that bit too, but I must have done > something wrong... Well, you dug up an old bug and turned our attention to it, so in a = sense you did bring about the resolution! Patch pushed and bug closed (again). From unknown Fri Aug 15 20:29:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 12 Oct 2020 11:24:12 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator