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, 01 Jan 2017 20:41:57 +0200 Message-ID: <83zijafwqy.fsf@gnu.org> References: <87twc6tl0i.fsf@users.sourceforge.net> <83h97nlknj.fsf@gnu.org> <87mvhdoh4q.fsf@users.sourceforge.net> <83zilcipcr.fsf@gnu.org> <87a8d4lyzo.fsf@users.sourceforge.net> <83a8d3cq9s.fsf@gnu.org> <87wpg5l9st.fsf@users.sourceforge.net> <83d1hwhgdi.fsf@gnu.org> <87r36ckzca.fsf@users.sourceforge.net> <83polvfl3h.fsf@gnu.org> <87oa1fknx9.fsf@users.sourceforge.net> <83y40idqm3.fsf@gnu.org> <87lguu7hq8.fsf@users.sourceforge.net> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1483296200 19563 195.159.176.226 (1 Jan 2017 18:43:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 1 Jan 2017 18:43:20 +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 Jan 01 19:43:15 2017 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 1cNl67-000406-Or for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Jan 2017 19:43:11 +0100 Original-Received: from localhost ([::1]:54192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cNl6B-0005xN-IY for geb-bug-gnu-emacs@m.gmane.org; Sun, 01 Jan 2017 13:43:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cNl61-0005w6-OE for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2017 13:43:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cNl5y-00014n-Kc for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2017 13:43:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51619) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cNl5y-00014h-GN for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2017 13:43:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cNl5y-0005pO-AD for bug-gnu-emacs@gnu.org; Sun, 01 Jan 2017 13:43: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, 01 Jan 2017 18:43: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.148329613622343 (code B ref 24751); Sun, 01 Jan 2017 18:43:02 +0000 Original-Received: (at 24751) by debbugs.gnu.org; 1 Jan 2017 18:42:16 +0000 Original-Received: from localhost ([127.0.0.1]:38785 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cNl5E-0005oJ-Is for submit@debbugs.gnu.org; Sun, 01 Jan 2017 13:42:16 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57049) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cNl5D-0005o6-Nv for 24751@debbugs.gnu.org; Sun, 01 Jan 2017 13:42:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cNl55-0000h6-J0 for 24751@debbugs.gnu.org; Sun, 01 Jan 2017 13:42:10 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:59415) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cNl55-0000h1-F9; Sun, 01 Jan 2017 13:42:07 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2997 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cNl52-0001Ow-M9; Sun, 01 Jan 2017 13:42:07 -0500 In-reply-to: <87lguu7hq8.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:127661 Archived-At: > From: npostavs@users.sourceforge.net > Cc: 24751@debbugs.gnu.org > Date: Sun, 01 Jan 2017 13:33:35 -0500 > > Eli Zaretskii writes: > >> > >> /* Define MATCH_MAY_ALLOCATE unless we need to make sure that the > >> searching and matching functions should not call alloca. On some > >> systems, alloca is implemented in terms of malloc, and if we're > >> using the relocating allocator routines, then malloc could cause a > >> relocation, which might (if the strings being searched are in the > >> ralloc heap) shift the data out from underneath the regexp > >> routines. > >> > >> [...] > > > > The first part is not obsolete, but its reasoning is backwards: > > SAFE_ALLOCA indeed can call malloc, but it could only cause relocation > > if REGEX_MALLOC is defined (and ralloc.c is compiled in). And when > > you define REGEX_MALLOC, MATCH_MAY_ALLOCATE is undefined. So the text > > there should be revised. > > Is there ever any case where REGEX_MALLOC is defined? I can't see where > it happens. I don't understand the question. You can compile regex.c with the "-DREGEX_MALLOC" option whenever you like. We don't do that, but as long as the code which supports that is in regex.c, the comment goes with it. > I don't understand why you say relocation is dependent on > REGEX_MALLOC, I thought only REL_ALLOC affects that. REL_ALLOC determines whether ralloc.c is compiled in, which I mentioned above. > And since we added r_alloc_inhibit_buffer_relocation around the regex > calls, aren't all these concerns about relocation obsolete? The calls to r_alloc_inhibit_buffer_relocation are outside of regex.c, so the comments in regex.c don't know anything about that.