unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Richard Copley <rcopley@gmail.com>
Cc: 40661@debbugs.gnu.org
Subject: bug#40661: Crash in regex search during redisplay
Date: Thu, 16 Apr 2020 18:36:36 +0300	[thread overview]
Message-ID: <83ftd3e92z.fsf@gnu.org> (raw)
In-Reply-To: <CAPM58og2SBLJ=NiDhm=TbE5WFzr6b3VTfSJXesSEd_VQ_u80PQ@mail.gmail.com> (message from Richard Copley on Thu, 16 Apr 2020 15:35:20 +0100)

> 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	other threads:[~2020-04-16 15:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16 14:35 bug#40661: Crash in regex search during redisplay Richard Copley
2020-04-16 15:36 ` Eli Zaretskii [this message]
2020-04-16 16:33   ` Eli Zaretskii
2020-04-16 16:42     ` Daniel Colascione
2020-04-16 16:56       ` Richard Copley
2020-04-16 17:24         ` Daniel Colascione
2020-04-16 19:35           ` Richard Copley
2020-04-17 11:22             ` Eli Zaretskii
2020-04-17 13:55               ` Eli Zaretskii
2020-04-17 14:01                 ` Daniel Colascione
2020-04-17 15:28               ` Stefan Monnier
2020-04-17 15:50                 ` Eli Zaretskii
2020-04-17 16:00                   ` Stefan Monnier
2020-04-18 11:57                     ` Eli Zaretskii
2020-04-20 18:30                       ` Richard Copley
2020-04-20 19:06                         ` Eli Zaretskii
2020-04-20 23:04                           ` Richard Copley
2020-09-30  3:49                             ` Lars Ingebrigtsen
2020-04-16 16:57       ` 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=83ftd3e92z.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=40661@debbugs.gnu.org \
    --cc=rcopley@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 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).