From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Sam Halliday Newsgroups: gmane.emacs.bugs Subject: bug#24358: 25.1.50; re-search-forward errors with "Variable binding depth exceeds max-specpdl-size" Date: Sun, 23 Oct 2016 21:15:11 +0100 Message-ID: References: <87eg3rvtsf.fsf@users.sourceforge.net> <83k2dihpm9.fsf@gnu.org> <8760p2wzgj.fsf@users.sourceforge.net> <838ttyhhzu.fsf@gnu.org> <871szqwu51.fsf@users.sourceforge.net> <831szqhbc2.fsf@gnu.org> <87h98hujcx.fsf@users.sourceforge.net> <831szkahyz.fsf@gnu.org> <87eg3jvfj6.fsf@users.sourceforge.net> <8360ov8lbu.fsf@gnu.org> <877f95uj66.fsf@users.sourceforge.net> <83zim0vn1t.fsf@gnu.org> <874m48v7wj.fsf@users.sourceforge.net> <83insov1zr.fsf@gnu.org> <87zilztzd5.fsf@users.sourceforge.net> <83oa2ftnvp.fsf@gnu.org> <87wph2ts1a.fsf@users.sourceforge.net> <83oa2erx0k.fsf@gnu.org> <87lgxht8hp.fsf@users.sourceforge.net> <871sz8kq2v.fsf@gmail.com> <87shroroh8.fsf@users.sourceforge.net> <838ttfpnxt.fsf@gnu.org> <83vawjo21l.fsf@gnu.org> <83bmybnopx.fsf@gnu.org> <8360ojnk0n.fsf@gnu.org> <83twc3m198.fsf@gnu.org> <83pomrlz27.fsf@gnu.org> <83lgxenao0.fsf@gnu.org> <83insin9n8.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1477253779 1090 195.159.176.226 (23 Oct 2016 20:16:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 23 Oct 2016 20:16:19 +0000 (UTC) Cc: 24358@debbugs.gnu.org, Noam Postavsky To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 23 22:16:15 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 1byPBj-0007m2-TC for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Oct 2016 22:16:12 +0200 Original-Received: from localhost ([::1]:42278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byPBl-0000D0-UO for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Oct 2016 16:16:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byPBe-0000Ce-EE for bug-gnu-emacs@gnu.org; Sun, 23 Oct 2016 16:16:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byPBa-00089I-Cx for bug-gnu-emacs@gnu.org; Sun, 23 Oct 2016 16:16:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34741) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1byPBa-00089D-85 for bug-gnu-emacs@gnu.org; Sun, 23 Oct 2016 16:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1byPBa-0000wM-2o for bug-gnu-emacs@gnu.org; Sun, 23 Oct 2016 16:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sam Halliday Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 23 Oct 2016 20:16:02 +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 fixed Original-Received: via spool by 24358-submit@debbugs.gnu.org id=B24358.14772537203562 (code B ref 24358); Sun, 23 Oct 2016 20:16:02 +0000 Original-Received: (at 24358) by debbugs.gnu.org; 23 Oct 2016 20:15:20 +0000 Original-Received: from localhost ([127.0.0.1]:50137 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byPAu-0000vN-7U for submit@debbugs.gnu.org; Sun, 23 Oct 2016 16:15:20 -0400 Original-Received: from mail-yw0-f169.google.com ([209.85.161.169]:35930) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byPAs-0000vA-8k for 24358@debbugs.gnu.org; Sun, 23 Oct 2016 16:15:18 -0400 Original-Received: by mail-yw0-f169.google.com with SMTP id u124so145854800ywg.3 for <24358@debbugs.gnu.org>; Sun, 23 Oct 2016 13:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=E9FEVm4Cbgba6EXaegzAjnXLcUN/SdnsLG4dITNBbTI=; b=NSaQc1aoqRGzDEIFbOvINUtOjA5jVv0MUpWx2im5hYtmDShFgxqiVXJd9R+m0gXNA/ wHt2vmWOjP8fWM3OVbkamGj+/lmqYQ/gtHQ0nb80MSrzT9Z5NGvZKCnFV47GcQKLLb62 9msJfeyf/RHzC88dyqOKqfLJCHh6QFgSEatbnjRdeMgQqPdmVaOWmXyyv16NkOe5aF5J y9XeANce0Lx8N/5LQKUkGBq10DYCXfK6FHeUM1vspInDxRHklyX9ClQd1nAFZaovWFVY +Xn9Sezjy2MpbZ3WBClg5NR5I19XlCrkdVKlz4eGPboML/6bLPY/Avm4IZro87UoYV4F +dUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=E9FEVm4Cbgba6EXaegzAjnXLcUN/SdnsLG4dITNBbTI=; b=f3CLwXru8thWjxOjvFRlfnQyfshzkVkpHKBTuHBBXWjlTPAfm4nh4ML3nIe8szHRfy 7+z8GcyQecpyfYA4QImvVNAo3uCEryQzYk27NWy1Sx/MbLNCZQ6Q8OtnYyh5IcEf3SqH ZRyIFhn4u7KA6/420e0UbfsBQXkQhL/C55vA1LpLLNJNphnrhud7pJq+jRNU0oW6uUdN HFB9ysY4OQFetuVgCkmK2o+OUdj9GbvizdVpf3OK8ucLvNHa9ZHB6qTRS6vFbNlJPKpH cZ6YonbuuNyjI3air+tp0iJNaOKuZZ9q7kQewQYSZ9H93HLP5orbC+PYWgzcPGHZALf4 L3mg== X-Gm-Message-State: ABUngvd5kEyiMLgM+tx54yrsSUigKh1/e/aJ74VsjcGA9wr5XsdWPp5R0TNUjIccoimYGGj6LLD2v62IkM80oQ== X-Received: by 10.107.168.213 with SMTP id e82mr12334938ioj.21.1477253712392; Sun, 23 Oct 2016 13:15:12 -0700 (PDT) Original-Received: by 10.50.40.3 with HTTP; Sun, 23 Oct 2016 13:15:11 -0700 (PDT) In-Reply-To: <83insin9n8.fsf@gnu.org> 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:124932 Archived-At: Sorry Eli, this patch doesn't apply cleanly for me. I'm on the tip of emacs-25 and I get failures in dired.c, regex.c and search.c that aren't easy for me to resolve. I'm happy to keep being guinea pig so you can fix this, but as a workaround so that I can have a more stable Emacs to get my main work done, is there a way for me to force the use of a less jumpy malloc implementation? It sounds like whatever happened in ArchLinux has meant that Emacs now prefers ralloc whereas previously it may not. On 23 October 2016 at 20:32, Eli Zaretskii wrote: >> Date: Sun, 23 Oct 2016 22:10:55 +0300 >> From: Eli Zaretskii >> Cc: 24358@debbugs.gnu.org, npostavs@users.sourceforge.net >> >> The problem is to find the code which causes this. Hmm... > > Sam, the patch below removes the changes done by Noam in an attempt to > solve the original report of this bug. Please apply it, and see if > doing so allows you to complete your bootstrap without any errors. > > Noam, do you configure Emacs with --enable-check-lisp-object-type? > If not, please do, because that's what Sam does; perhaps that is the > reason why he gets the problem and you don't. > > One other difference is that Sam is running a bootstrap, so his > bootstrap-emacs used to build ja-dic has the necessary Lisp files > loaded as *.el files, not *.elc. Therefore another thing to try > (perhaps even before reconfiguring) is a full bootstrap, preferably in > a separate clean directory, maybe you will see this problem then. > > Your systems seem to be similar, so I'd expect you both to see the > same problems. > > Here's the patch to remove Noam's changes and Paul's follow-up > changes: > > diff --git a/src/dired.c b/src/dired.c > index 006f74c..dba575c 100644 > --- a/src/dired.c > +++ b/src/dired.c > @@ -259,11 +259,9 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, > QUIT; > > bool wanted = (NILP (match) > - || (re_match_object = name, > - re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0)); > + || re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0); > > immediate_quit = 0; > - re_match_object = Qnil; /* Stop protecting name from GC. */ > > if (wanted) > { > diff --git a/src/regex.c b/src/regex.c > index b12e95b..164eb46 100644 > --- a/src/regex.c > +++ b/src/regex.c > @@ -152,8 +152,6 @@ > > /* Converts the pointer to the char to BEG-based offset from the start. */ > # define PTR_TO_OFFSET(d) POS_AS_IN_BUFFER (POINTER_TO_OFFSET (d)) > -/* Strings are 0-indexed, buffers are 1-indexed; we pun on the boolean > - result to get the right base index. */ > # define POS_AS_IN_BUFFER(p) ((p) + (NILP (re_match_object) || BUFFERP (re_match_object))) > > # define RE_MULTIBYTE_P(bufp) ((bufp)->multibyte) > @@ -1438,62 +1436,11 @@ typedef struct > #define NEXT_FAILURE_HANDLE(h) fail_stack.stack[(h) - 3].integer > #define TOP_FAILURE_HANDLE() fail_stack.frame > > -#ifdef emacs > -# define STR_BASE_PTR(obj) \ > - (NILP (obj) ? current_buffer->text->beg \ > - : STRINGP (obj) ? SDATA (obj) \ > - : NULL) > -#else > -# define STR_BASE_PTR(obj) NULL > -#endif > > #define ENSURE_FAIL_STACK(space) \ > while (REMAINING_AVAIL_SLOTS <= space) { \ > - re_char *orig_base = STR_BASE_PTR (re_match_object); \ > - bool might_relocate = orig_base != NULL; \ > - ptrdiff_t string1_off, end1_off, end_match_1_off; \ > - ptrdiff_t string2_off, end2_off, end_match_2_off; \ > - ptrdiff_t d_off, dend_off, dfail_off; \ > - if (might_relocate) \ > - { \ > - if (string1) \ > - { \ > - string1_off = string1 - orig_base; \ > - end1_off = end1 - orig_base; \ > - end_match_1_off = end_match_1 - orig_base; \ > - } \ > - if (string2) \ > - { \ > - string2_off = string2 - orig_base; \ > - end2_off = end2 - orig_base; \ > - end_match_2_off = end_match_2 - orig_base; \ > - } \ > - d_off = d - orig_base; \ > - dend_off = dend - orig_base; \ > - dfail_off = dfail - orig_base; \ > - } \ > if (!GROW_FAIL_STACK (fail_stack)) \ > return -2; \ > - /* In Emacs, GROW_FAIL_STACK might relocate string pointers. */ \ > - if (might_relocate) \ > - { \ > - re_char *new_base = STR_BASE_PTR (re_match_object); \ > - if (string1) \ > - { \ > - string1 = new_base + string1_off; \ > - end1 = new_base + end1_off; \ > - end_match_1 = new_base + end_match_1_off; \ > - } \ > - if (string2) \ > - { \ > - string2 = new_base + string2_off; \ > - end2 = new_base + end2_off; \ > - end_match_2 = new_base + end_match_2_off; \ > - } \ > - d = new_base + d_off; \ > - dend = new_base + dend_off; \ > - dfail = new_base + dfail_off; \ > - } \ > DEBUG_PRINT ("\n Doubled stack; size now: %zd\n", (fail_stack).size);\ > DEBUG_PRINT (" slots available: %zd\n", REMAINING_AVAIL_SLOTS);\ > } > @@ -4380,10 +4327,6 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1, > /* Loop through the string, looking for a place to start matching. */ > for (;;) > { > - ptrdiff_t offset1, offset2; > - re_char *orig_base; > - bool might_relocate; > - > /* If the pattern is anchored, > skip quickly past places we cannot match. > We don't bother to treat startpos == 0 specially > @@ -4500,17 +4443,6 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1, > && !bufp->can_be_null) > return -1; > > - /* re_match_2_internal may allocate, relocating the Lisp text > - object that we're searching. */ > - IF_LINT (offset2 = 0); /* Work around GCC bug 78081. */ > - orig_base = STR_BASE_PTR (re_match_object); > - might_relocate = orig_base != NULL; > - if (might_relocate) > - { > - if (string1) offset1 = string1 - orig_base; > - if (string2) offset2 = string2 - orig_base; > - } > - > val = re_match_2_internal (bufp, string1, size1, string2, size2, > startpos, regs, stop); > > @@ -4520,13 +4452,6 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1, > if (val == -2) > return -2; > > - if (might_relocate) > - { > - re_char *new_base = STR_BASE_PTR (re_match_object); > - if (string1) string1 = offset1 + new_base; > - if (string2) string2 = offset2 + new_base; > - } > - > advance: > if (!range) > break; > @@ -4962,8 +4887,8 @@ WEAK_ALIAS (__re_match, re_match) > #endif /* not emacs */ > > #ifdef emacs > -/* In Emacs, this is the string or buffer in which we are matching. > - See the declaration in regex.h for details. */ > +/* In Emacs, this is the string or buffer in which we > + are matching. It is used for looking up syntax properties. */ > Lisp_Object re_match_object; > #endif > > diff --git a/src/search.c b/src/search.c > index 5c04916..dc7e2d8 100644 > --- a/src/search.c > +++ b/src/search.c > @@ -287,10 +287,8 @@ looking_at_1 (Lisp_Object string, bool posix) > immediate_quit = 1; > QUIT; /* Do a pending quit right away, to avoid paradoxical behavior */ > > - /* Get pointers and sizes of the two strings that make up the > - visible portion of the buffer. Note that we can use pointers > - here, unlike in search_buffer, because we only call re_match_2 > - once, after which we never use the pointers again. */ > + /* Get pointers and sizes of the two strings > + that make up the visible portion of the buffer. */ > > p1 = BEGV_ADDR; > s1 = GPT_BYTE - BEGV_BYTE; > @@ -409,7 +407,6 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, > (NILP (Vinhibit_changing_match_data) > ? &search_regs : NULL)); > immediate_quit = 0; > - re_match_object = Qnil; /* Stop protecting string from GC. */ > > /* Set last_thing_searched only when match data is changed. */ > if (NILP (Vinhibit_changing_match_data)) > @@ -480,7 +477,6 @@ fast_string_match_internal (Lisp_Object regexp, Lisp_Object string, > SBYTES (string), 0, > SBYTES (string), 0); > immediate_quit = 0; > - re_match_object = Qnil; /* Stop protecting string from GC. */ > return val; > } > > @@ -568,7 +564,6 @@ fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte, > len = re_match_2 (buf, (char *) p1, s1, (char *) p2, s2, > pos_byte, NULL, limit_byte); > immediate_quit = 0; > - re_match_object = Qnil; /* Stop protecting string from GC. */ > > return len; > } > @@ -1183,8 +1178,8 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, > > if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp))) > { > - unsigned char *base; > - ptrdiff_t off1, off2, s1, s2; > + unsigned char *p1, *p2; > + ptrdiff_t s1, s2; > struct re_pattern_buffer *bufp; > > bufp = compile_pattern (string, > @@ -1198,19 +1193,16 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, > can take too long. */ > QUIT; /* Do a pending quit right away, > to avoid paradoxical behavior */ > - /* Get offsets and sizes of the two strings that make up the > - visible portion of the buffer. We compute offsets instead of > - pointers because re_search_2 may call malloc and therefore > - change the buffer text address. */ > + /* Get pointers and sizes of the two strings > + that make up the visible portion of the buffer. */ > > - base = current_buffer->text->beg; > - off1 = BEGV_ADDR - base; > + p1 = BEGV_ADDR; > s1 = GPT_BYTE - BEGV_BYTE; > - off2 = GAP_END_ADDR - base; > + p2 = GAP_END_ADDR; > s2 = ZV_BYTE - GPT_BYTE; > if (s1 < 0) > { > - off2 = off1; > + p2 = p1; > s2 = ZV_BYTE - BEGV_BYTE; > s1 = 0; > } > @@ -1225,16 +1217,12 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, > { > ptrdiff_t val; > > - val = re_search_2 (bufp, > - (char*) (base + off1), s1, > - (char*) (base + off2), s2, > + val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, > pos_byte - BEGV_BYTE, lim_byte - pos_byte, > (NILP (Vinhibit_changing_match_data) > ? &search_regs : &search_regs_1), > /* Don't allow match past current point */ > pos_byte - BEGV_BYTE); > - /* Update 'base' due to possible relocation inside re_search_2. */ > - base = current_buffer->text->beg; > if (val == -2) > { > matcher_overflow (); > @@ -1274,15 +1262,11 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, > { > ptrdiff_t val; > > - val = re_search_2 (bufp, > - (char*) (base + off1), s1, > - (char*) (base + off2), s2, > - pos_byte - BEGV_BYTE, lim_byte - pos_byte, > + val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, > + pos_byte - BEGV_BYTE, lim_byte - pos_byte, > (NILP (Vinhibit_changing_match_data) > ? &search_regs : &search_regs_1), > lim_byte - BEGV_BYTE); > - /* Update 'base' due to possible relocation inside re_search_2. */ > - base = current_buffer->text->beg; > if (val == -2) > { > matcher_overflow ();