unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] emacs-25 8121757: Fix regex abort when it tries to reenter itself
       [not found] ` <E1ZxtPX-0006VO-43@vcs.savannah.gnu.org>
@ 2015-11-16 17:21   ` Stefan Monnier
  2015-11-16 21:11     ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Monnier @ 2015-11-16 17:21 UTC (permalink / raw)
  To: emacs-devel; +Cc: Paul Eggert

> -update_syntax_table_forward (ptrdiff_t charpos, bool init,
> +update_syntax_table_forward (ptrdiff_t charpos, bool init, bool propertize,
>  			     Lisp_Object object)
>  {
>    if (gl_state.e_property_truncated)
>      {
>        eassert (NILP (object));
>        eassert (charpos >= gl_state.e_property);
> -      parse_sexp_propertize (charpos);
>      }

If propertize is false, you end up not doing anything at all, which is
wrong.  This said, when propertize is false, we should (make sure we)
*never* come here anyway.

>    else
>      {
>        update_syntax_table (charpos, 1, init, object);
> -      if (gl_state.e_property > syntax_propertize__done
> -	  && NILP (object))
> -	parse_sexp_propertize (charpos);
> +      propertize &= (NILP (object)
> +		     && gl_state.e_property > syntax_propertize__done);

So when propertize is false, we just call update_syntax_table and do
nothing else.  So, rather than add a `propertize' argument, we'd be
better off just calling update_syntax_table directly from
UPDATE_SYNTAX_TABLE_FORWARD_FAST.


        Stefan



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Emacs-diffs] emacs-25 8121757: Fix regex abort when it tries to reenter itself
  2015-11-16 17:21   ` [Emacs-diffs] emacs-25 8121757: Fix regex abort when it tries to reenter itself Stefan Monnier
@ 2015-11-16 21:11     ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2015-11-16 21:11 UTC (permalink / raw)
  To: Stefan Monnier, emacs-devel

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

On 11/16/2015 09:21 AM, Stefan Monnier wrote:
> rather than add a `propertize' argument, we'd be
> better off just calling update_syntax_table directly from
> UPDATE_SYNTAX_TABLE_FORWARD_FAST

Thanks for the review, and I did as you suggested by installing the 
attached into the emacs-25 branch.

[-- Attachment #2: 0001-Improve-fix-for-regex-reentrancy-abort.patch --]
[-- Type: text/x-patch, Size: 3395 bytes --]

From 15a56a48b746ff77af0151336bb4de237afa6d03 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 16 Nov 2015 13:09:46 -0800
Subject: [PATCH] Improve fix for regex reentrancy abort

Suggested by Stefan Monnier (Bug#21688).
* src/syntax.c (update_syntax_table_forward):
Remove recently-added PROPERTIZE arg, and assume it is true.
All callers changed.
* src/syntax.h (UPDATE_SYNTAX_TABLE_FORWARD_FAST):
Invoke update_syntax_table directly.
---
 src/syntax.c | 13 +++++--------
 src/syntax.h |  7 +++----
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/syntax.c b/src/syntax.c
index 687bef7..f939a76 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -246,7 +246,7 @@ SETUP_SYNTAX_TABLE (ptrdiff_t from, ptrdiff_t count)
   if (parse_sexp_lookup_properties)
     {
       if (count > 0)
-	update_syntax_table_forward (from, true, true, Qnil);
+	update_syntax_table_forward (from, true, Qnil);
       else if (from > BEGV)
 	{
 	  update_syntax_table (from - 1, count, true, Qnil);
@@ -502,12 +502,12 @@ parse_sexp_propertize (ptrdiff_t charpos)
 	 e_property_truncated, so the e_property_truncated flag may
 	 occasionally be left raised spuriously.  This should be rare.  */
       gl_state.e_property_truncated = false;
-      update_syntax_table_forward (charpos, false, true, Qnil);
+      update_syntax_table_forward (charpos, false, Qnil);
     }
 }
 
 void
-update_syntax_table_forward (ptrdiff_t charpos, bool init, bool propertize,
+update_syntax_table_forward (ptrdiff_t charpos, bool init,
 			     Lisp_Object object)
 {
   if (gl_state.e_property_truncated)
@@ -518,12 +518,9 @@ update_syntax_table_forward (ptrdiff_t charpos, bool init, bool propertize,
   else
     {
       update_syntax_table (charpos, 1, init, object);
-      propertize &= (NILP (object)
-		     && gl_state.e_property > syntax_propertize__done);
+      if (NILP (object) && gl_state.e_property > syntax_propertize__done)
+	parse_sexp_propertize (charpos);
     }
-
-  if (propertize)
-    parse_sexp_propertize (charpos);
 }
 \f
 /* Returns true if char at CHARPOS is quoted.
diff --git a/src/syntax.h b/src/syntax.h
index 01c92ae..eb154e0 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -27,7 +27,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 INLINE_HEADER_BEGIN
 
 extern void update_syntax_table (ptrdiff_t, EMACS_INT, bool, Lisp_Object);
-extern void update_syntax_table_forward (ptrdiff_t, bool, bool, Lisp_Object);
+extern void update_syntax_table_forward (ptrdiff_t, bool, Lisp_Object);
 
 /* The standard syntax table is stored where it will automatically
    be used in all new buffers.  */
@@ -183,15 +183,14 @@ UPDATE_SYNTAX_TABLE_FORWARD (ptrdiff_t charpos)
 { /* Performs just-in-time syntax-propertization.  */
   if (parse_sexp_lookup_properties && charpos >= gl_state.e_property)
     update_syntax_table_forward (charpos + gl_state.offset,
-				 false, true, gl_state.object);
+				 false, gl_state.object);
 }
 
 INLINE void
 UPDATE_SYNTAX_TABLE_FORWARD_FAST (ptrdiff_t charpos)
 {
   if (parse_sexp_lookup_properties && charpos >= gl_state.e_property)
-    update_syntax_table_forward (charpos + gl_state.offset,
-				 false, false, gl_state.object);
+    update_syntax_table (charpos + gl_state.offset, 1, false, gl_state.object);
 }
 
 /* Make syntax table state (gl_state) good for CHARPOS, assuming it is
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-16 21:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20151115091547.24972.63172@vcs.savannah.gnu.org>
     [not found] ` <E1ZxtPX-0006VO-43@vcs.savannah.gnu.org>
2015-11-16 17:21   ` [Emacs-diffs] emacs-25 8121757: Fix regex abort when it tries to reenter itself Stefan Monnier
2015-11-16 21:11     ` Paul Eggert

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).