unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Richard Copley <rcopley@gmail.com>, 40661@debbugs.gnu.org
Subject: bug#40661: Crash in regex search during redisplay
Date: Fri, 17 Apr 2020 11:28:49 -0400	[thread overview]
Message-ID: <jwvwo6e9lv7.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <838siucq7b.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 17 Apr 2020 14:22:00 +0300")

> I finally succeeded to build a sophisticated enough trap to catch the
> culprit.  It's GC allright.  Which is not surprising: the commit
> pointed out by Richard changed re_match_2_internal to call
> UPDATE_SYNTAX_TABLE_FORWARD, which calls Lisp, and thus can trigger
> GC.  As seen from the backtrace, GC then calls compact_buffer, which
> calls enlarge_buffer_text (to shrink buffer text), and on MS-Windows
> -- and this is the w32-specific part -- we return some memory to the
> OS and relocate buffer text.
>
> Obviously, we cannot allow GC to run while regex routines do their
> work, because they are passed C pointers to buffer text.  The question
> is, where to disable GC?  We could do it inside
> update_syntax_table_forward, but UPDATE_SYNTAX_TABLE_FORWARD is called
> from many places that evidently have no problems with GC.  So my
> suggestion would be to disable GC inside re_match_2_internal instead.
>
> Comments?

Looks fine to me.  I think a better fix is to move the execution of
compact_buffer: there's no reason it has to be done during GC, we just
need to do it "every once in a while" and the GC was a convenient point
for that.  But we could avoid several such problems if we were to run
such background tasks elsewhere.  It could still be linked to GC,
e.g. we could start a timer during the GC so its run at the next
opportunity.


        Stefan






  parent reply	other threads:[~2020-04-17 15:28 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
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 [this message]
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=jwvwo6e9lv7.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=40661@debbugs.gnu.org \
    --cc=eliz@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).