all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: schwab@suse.de, 23704@debbugs.gnu.org, vincent.belaiche@gmail.com
Subject: bug#23704: 25.1.50; Emacs crash in syntax.c
Date: Tue, 7 Jun 2016 00:26:55 -0700	[thread overview]
Message-ID: <5756773F.4050801@cs.ucla.edu> (raw)
In-Reply-To: <83r3c9soy0.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

Eli Zaretskii wrote:
> I think we need to fix the rest on the release branch as well.

Ah, sorry, I got confused by the phrase "release branch", and thought the phrase 
referred to master instead of to emacs-25. Anyway, attached is a revised patch 
that I think fixes the whole problem.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-crash-in-syntax.c-after-GC.patch --]
[-- Type: text/x-diff; name="0001-Fix-crash-in-syntax.c-after-GC.patch", Size: 3029 bytes --]

From 2537a82e008e02fb620223509993c035e9645564 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 6 Jun 2016 22:37:12 -0700
Subject: [PATCH] Fix crash in syntax.c after GC
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Vincent Belaïche (Bug#23704).
* src/syntax.c (skip_chars): Recompute pointers into the
buffer after every call to update_syntax_table_forward,
as it can GC.
---
 src/syntax.c | 59 ++++++++++++++++++++++++-----------------------------------
 1 file changed, 24 insertions(+), 35 deletions(-)

diff --git a/src/syntax.c b/src/syntax.c
index 16b7fab..6f53684 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -2171,63 +2171,51 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
     ptrdiff_t start_point = PT;
     ptrdiff_t pos = PT;
     ptrdiff_t pos_byte = PT_BYTE;
-    unsigned char *p = PT_ADDR, *endp, *stop;
-
-    if (forwardp)
-      {
-	endp = (XINT (lim) == GPT) ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim));
-	stop = (pos < GPT && GPT < XINT (lim)) ? GPT_ADDR : endp;
-      }
-    else
-      {
-	endp = CHAR_POS_ADDR (XINT (lim));
-	stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp;
-      }
+    unsigned char *p, *endp, *stop;
 
     immediate_quit = 1;
     SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1);
+
     if (forwardp)
       {
-	if (multibyte)
+	while (true)
 	  {
-	    while (1)
+	    p = BYTE_POS_ADDR (pos_byte);
+	    endp = XINT (lim) == GPT ? GPT_ADDR : CHAR_POS_ADDR (XINT (lim));
+	    stop = pos < GPT && GPT < XINT (lim) ? GPT_ADDR : endp;
+
+	    do
 	      {
 		int nbytes;
 
 		if (p >= stop)
 		  {
 		    if (p >= endp)
-		      break;
+		      goto done;
 		    p = GAP_END_ADDR;
 		    stop = endp;
 		  }
-		c = STRING_CHAR_AND_LENGTH (p, nbytes);
+		if (multibyte)
+		  c = STRING_CHAR_AND_LENGTH (p, nbytes);
+		else
+		  c = *p, nbytes = 1;
 		if (! fastmap[SYNTAX (c)])
-		  break;
+		  goto done;
 		p += nbytes, pos++, pos_byte += nbytes;
-		UPDATE_SYNTAX_TABLE_FORWARD (pos);
-	      }
-	  }
-	else
-	  {
-	    while (1)
-	      {
-		if (p >= stop)
-		  {
-		    if (p >= endp)
-		      break;
-		    p = GAP_END_ADDR;
-		    stop = endp;
-		  }
-		if (! fastmap[SYNTAX (*p)])
-		  break;
-		p++, pos++, pos_byte++;
-		UPDATE_SYNTAX_TABLE_FORWARD (pos);
 	      }
+	    while (!parse_sexp_lookup_properties
+		   || pos < gl_state.e_property);
+
+	    update_syntax_table_forward (pos + gl_state.offset,
+					 false, gl_state.object);
 	  }
       }
     else
       {
+	p = BYTE_POS_ADDR (pos_byte);
+	endp = CHAR_POS_ADDR (XINT (lim));
+	stop = pos >= GPT && GPT > XINT (lim) ? GAP_END_ADDR : endp;
+
 	if (multibyte)
 	  {
 	    while (1)
@@ -2269,6 +2257,7 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
 	  }
       }
 
+  done:
     SET_PT_BOTH (pos, pos_byte);
     immediate_quit = 0;
 
-- 
2.5.5


  reply	other threads:[~2016-06-07  7:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-06  5:25 bug#23704: 25.1.50; Emacs crash in syntax.c Vincent Belaïche
2016-06-06  7:36 ` Andreas Schwab
2016-06-06 14:52   ` Eli Zaretskii
2016-06-06 15:03     ` Andreas Schwab
2016-06-06 14:49 ` Eli Zaretskii
2016-06-06 16:14   ` Vincent Belaïche
2016-06-06 18:45     ` Eli Zaretskii
2016-06-06 17:17 ` Paul Eggert
2016-06-06 18:58   ` Eli Zaretskii
2016-06-06 20:07     ` Paul Eggert
2016-06-07  2:38       ` Eli Zaretskii
2016-06-07  7:26         ` Paul Eggert [this message]
2016-06-07 15:52           ` Eli Zaretskii
2016-06-07 16:36             ` Paul Eggert
2016-06-07 17:17               ` Eli Zaretskii
2016-06-07 21:46                 ` Vincent Belaïche
2016-06-07 22:11                   ` Paul Eggert
2016-06-08  5:34                     ` Vincent Belaïche
2016-06-08 16:41                       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5756773F.4050801@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=23704@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=schwab@suse.de \
    --cc=vincent.belaiche@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.