From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#24358: 25.1.50; re-search-forward errors with "Variable binding depth exceeds max-specpdl-size" Date: Sat, 03 Sep 2016 11:43:16 -0400 Message-ID: <87eg51ng4r.fsf_-_@users.sourceforge.net> References: <87twe6sx2g.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1472917467 14953 195.159.176.226 (3 Sep 2016 15:44:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 3 Sep 2016 15:44:27 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: 24358@debbugs.gnu.org To: peder@klingenberg.no (Peder O. Klingenberg) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 03 17:44:23 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgD7A-0002p7-Rz for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Sep 2016 17:44:17 +0200 Original-Received: from localhost ([::1]:46874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgD78-0003Pf-ML for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Sep 2016 11:44:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgD70-0003O7-B6 for bug-gnu-emacs@gnu.org; Sat, 03 Sep 2016 11:44:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bgD6w-0006W7-0X for bug-gnu-emacs@gnu.org; Sat, 03 Sep 2016 11:44:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bgD6v-0006W3-T8 for bug-gnu-emacs@gnu.org; Sat, 03 Sep 2016 11:44:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bgD6v-0008CE-Ko for bug-gnu-emacs@gnu.org; Sat, 03 Sep 2016 11:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Sep 2016 15:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24358 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24358-submit@debbugs.gnu.org id=B24358.147291738431400 (code B ref 24358); Sat, 03 Sep 2016 15:44:01 +0000 Original-Received: (at 24358) by debbugs.gnu.org; 3 Sep 2016 15:43:04 +0000 Original-Received: from localhost ([127.0.0.1]:48836 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgD60-0008AO-AW for submit@debbugs.gnu.org; Sat, 03 Sep 2016 11:43:04 -0400 Original-Received: from mail-it0-f51.google.com ([209.85.214.51]:37833) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgD5y-00089j-6T; Sat, 03 Sep 2016 11:43:02 -0400 Original-Received: by mail-it0-f51.google.com with SMTP id e124so87993400ith.0; Sat, 03 Sep 2016 08:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=5/PyZrGjGDR0ssDrSTqb1XmUSax7Z5+ictIh9YJ+1sk=; b=nIzKvwcSvxKXZKX3lLgDbUxE1lIIvLAriUttbNvf5dHVinHn9tDQOy95hzAdUjhPsd E7lcD/FC3lPuG8LGwj8Dk4iKz9lKCpVGfHpbHA4JINwX44zU3+T5Fat82HqY0er3i+vh e0BroON61zXomlk+NmwNzjj6iCcFXq2RhifH25uqti2K6E/PXIIidCHbXRZTIMg8CyS/ e3Rgf71yblaF5bIJb6s7Di+obROQ0+Re++w0x5CYFVhJJwMmvBNx2UOZZ4zAkfYXSZ7/ BC2AcxkhQ1473iALSxBfXOtKiCLyfREyVzyQDQpWkSeLif2NrtOI0r9bagTn9ggQKlvF /HTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=5/PyZrGjGDR0ssDrSTqb1XmUSax7Z5+ictIh9YJ+1sk=; b=lkpsu50jYLrvrMoOQ8a0mYChey7HlovHpcfTY3xpWJk5WkdSlmzo02qCI6f9gCUFLG 3JI7D4Tkt9UZ4BqSiGfhSeDAY7OkLTdOy6jRLq6qSZgA+UK0+Ub262GJm6U7j1Jf2yxh TyMr/a871mpxYCjQ6WoSNCYJHr3MdalG0ThIe3cHI1/ixgeD/Yebj0egW0IPdxo/zQMW VuiXLGCqXXrYq+DJS2ZdasbHqio28xr9kO8yfQcwT4Wjt5xs7Oa9xT1lTBMAM9CmyH/7 Ff+ZfDZtm9SZ4P7XoF6qB34HNkIJ6l1iHJBRMNBYyWXa0IgTZgqCIfh+PVbd6nsvqXoa DvjA== X-Gm-Message-State: AE9vXwPp6yVVT/m7o5CGYIZBoPto8m/pscewkRt1Wg5c9etlKxAYwAaEDO+VvUC8umaChg== X-Received: by 10.107.59.66 with SMTP id i63mr5100625ioa.57.1472917376436; Sat, 03 Sep 2016 08:42:56 -0700 (PDT) Original-Received: from zony ([45.2.7.130]) by smtp.googlemail.com with ESMTPSA id q1sm4543772itb.2.2016.09.03.08.42.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Sep 2016 08:42:55 -0700 (PDT) In-Reply-To: <87twe6sx2g.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Fri, 26 Aug 2016 23:35:51 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:122886 Archived-At: # this cloned bug doesn't have a patch yet tags 24358 - patch quit npostavs@users.sourceforge.net writes: > (I'm also on GNU/Linux, Arch) I get the same max-specpdl-size error with > 25.1.50, with 24.5 (and below) I get (error "Stack overflow in regexp > matcher") The problem is that re_max_failures is set to 40001 (instead of the original 40000) in main()[1], which is a problem because of the GROW_FAIL_STACK uses (re_max_failures * TYPICAL_FAILURE_SIZE) as a cap on the amount to allocate, but ((fail_stack).size * sizeof (fail_stack_elt_t)) to calculate current allocation. Since TYPICAL_FAILURE_SIZE = 20 and sizeof (fail_stack_elt_t) = 8, and it seems that (fail_stack).size grows in increments of 3, when (fail_stack).avail is 99999 and (fail_stack).size reaches 100002: (fail_stack).size * sizeof (fail_stack_elt_t) => 800016 re_max_failures * TYPICAL_FAILURE_SIZE => 800020 ENSURE_FAIL_STACK(3) then loops indefinitely reallocating a stack of size 800020 again and again until the record_xmalloc fails to grow_specdl() (thus the "max-specpdl-size" error). ---------- So we we might want to fix the re_max_failures setting in main, but it doesn't quite make sense to me that GROW_FAIL_STACK relies on re_max_failures being a multiple of (sizeof (fail_stack_elt_t)). At the definition of TYPICAL_FAILURE_SIZE we have /* Estimate the size of data pushed by a typical failure stack entry. An estimate is all we need, because all we use this for is to choose a limit for how big to make the failure stack. */ /* BEWARE, the value `20' is hard-coded in emacs.c:main(). */ #define TYPICAL_FAILURE_SIZE 20 Why do we use an "estimate" here? What's wrong with just using (re_max_failures * sizeof (fail_stack_elt_t)) as the limit? Or should the limit actually be (re_max_failures * TYPICAL_FAILURE_SIZE * sizeof (fail_stack_elt_t))? ----------- 827 long lim = rlim.rlim_cur; (gdb) p rlim $1 = { rlim_cur = 8388608, rlim_max = 18446744073709551615 } (gdb) next 833 int ratio = 20 * sizeof (char *); (gdb) 834 ratio += ratio / 3; (gdb) 837 int extra = 200000; (gdb) p ratio $2 = 213 [...] (gdb) display ((newlim - extra) / ratio) 1: ((newlim - extra) / ratio) = 40000 (gdb) next 856 newlim += pagesize - 1; 1: ((newlim - extra) / ratio) = 40000 (gdb) 857 if (0 <= rlim.rlim_max && rlim.rlim_max < newlim) 1: ((newlim - extra) / ratio) = 40019 (gdb) 859 newlim -= newlim % pagesize; 1: ((newlim - extra) / ratio) = 40019 (gdb) 861 if (pagesize <= newlim - lim) 1: ((newlim - extra) / ratio) = 40001 (gdb) undisplay 1 (gdb) next 863 rlim.rlim_cur = newlim; (gdb) 864 if (setrlimit (RLIMIT_STACK, &rlim) == 0) (gdb) 865 lim = newlim; (gdb) 870 re_max_failures = lim < extra ? 0 : min (lim - extra, SIZE_MAX) / ratio; (gdb) 875 stack_bottom = &stack_bottom_variable; (gdb) p re_max_failures $3 = 40001 ----------- [1]: This was the case since 9d356f62 2016-05-27 "Robustify stack-size calculation"