bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#40661: Crash in regex search during redisplay


From: Eli Zaretskii
Subject: bug#40661: Crash in regex search during redisplay
Date: Thu, 16 Apr 2020 18:36:36 +0300

> From: Richard Copley <rcopley@gmail.com>
> Date: Thu, 16 Apr 2020 15:35:20 +0100
> 
> Recipe from emacs -Q:
> 
>     Save the text below in a file with extension ".pl".
>     Repeatedly: kill the buffer and visit the file again. (You can use
> C-x C-v for this.)
> 
> Emacs eventually encounters a segfault. Backtrace below.
> 
> The text is reduced from a real program that exhibited the problem.
> Repeating up to about 20 times is usually enough. You can use a
> keyboard macro, [C-x ( C-x C-v RET C-x e e e e e], holding down the
> 'e' key until you get the crash.

Looks like GC sometimes kicks in while we are inside re_search_2 and
have pointers to buffer text lying around.  This seems to fix the
crash for me:

diff --git a/src/search.c b/src/search.c
index 818bb4a..79423be 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1188,6 +1188,7 @@ search_buffer_re (Lisp_Object string, ptrdiff_t pos, 
ptrdiff_t pos_byte,
   ptrdiff_t count = SPECPDL_INDEX ();
   freeze_buffer_relocation ();
   freeze_pattern (cache_entry);
+  inhibit_garbage_collection ();
 
   while (n < 0)
     {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]