From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#24751: 26.0.50; Regex stack overflow not detected properly (gets "Variable binding depth exceeds max-specpdl-size") Date: Sun, 06 Nov 2016 17:45:40 +0200 Message-ID: <83zilcipcr.fsf@gnu.org> References: <87twc6tl0i.fsf@users.sourceforge.net> <83h97nlknj.fsf@gnu.org> <87mvhdoh4q.fsf@users.sourceforge.net> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1478447206 32074 195.159.176.226 (6 Nov 2016 15:46:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 6 Nov 2016 15:46:46 +0000 (UTC) Cc: 24751@debbugs.gnu.org To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Nov 06 16:46:41 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 1c3Pe5-0003kj-8C for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Nov 2016 16:46:09 +0100 Original-Received: from localhost ([::1]:44384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3Pe8-0004ZE-2w for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Nov 2016 10:46:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55150) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3Pe1-0004Z6-Bo for bug-gnu-emacs@gnu.org; Sun, 06 Nov 2016 10:46:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c3Pdy-0003Rm-PP for bug-gnu-emacs@gnu.org; Sun, 06 Nov 2016 10:46:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c3Pdy-0003Re-Kp for bug-gnu-emacs@gnu.org; Sun, 06 Nov 2016 10:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c3Pdy-00073z-Dr for bug-gnu-emacs@gnu.org; Sun, 06 Nov 2016 10:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Nov 2016 15:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24751 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24751-submit@debbugs.gnu.org id=B24751.147844712227070 (code B ref 24751); Sun, 06 Nov 2016 15:46:02 +0000 Original-Received: (at 24751) by debbugs.gnu.org; 6 Nov 2016 15:45:22 +0000 Original-Received: from localhost ([127.0.0.1]:47069 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c3PdK-00072Y-KL for submit@debbugs.gnu.org; Sun, 06 Nov 2016 10:45:22 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:35859) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c3PdI-00072H-MF for 24751@debbugs.gnu.org; Sun, 06 Nov 2016 10:45:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c3PdA-0002x1-LW for 24751@debbugs.gnu.org; Sun, 06 Nov 2016 10:45:15 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48919) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c3PdA-0002wr-Iu; Sun, 06 Nov 2016 10:45:12 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4672 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1c3Pd9-0005oh-Qc; Sun, 06 Nov 2016 10:45:12 -0500 In-reply-to: <87mvhdoh4q.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:125388 Archived-At: > From: npostavs@users.sourceforge.net > Cc: 24751@debbugs.gnu.org > Date: Sat, 05 Nov 2016 15:34:29 -0400 > > >> #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))? > > > > I think it should be the latter, indeed. > > > > Can you propose a patch along those lines that would remove the > > infloop in ENSURE_FAIL_STACK? > > > > Thanks. > > The below seems to work Thanks. I think the patch can be simplified, where we now multiply by the size of fail_stack_elt_t and then divide by it: simply remove both the multiplication and the division. That will make the code easier to read, and will make the units of each variable clear, something that I think is at the heart of this issue. > but effectively increases the size of the failure stack (so the > sample file size has to be increased 8-fold to get a regex stack > overflow). Which IMO is exactly TRT, since re_max_failures was computed given the runtime stack size of 8MB, so having it bail out after merely 800KB doesn't sound right to me, don't you agree? > Strangely, changing the value in the definition of re_max_failures > doesn't seem to have any effect, it stays 40000 regardless. I am > quite confused. I don't think I follow. Can you tell what you tried to change, and where did you see the lack of any effect?