GNU bug report logs - #35264
"Match data clobbered by buffer modification hooks" when hooks only shifted match-data's markers

Previous Next

Package: emacs;

Reported by: Noam Postavsky <npostavs <at> gmail.com>

Date: Sun, 14 Apr 2019 04:41:01 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #13 received at 35264 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: stefan monnier <monnier <at> iro.umontreal.ca>, 35264 <at> debbugs.gnu.org
Subject: Re: bug#35264: "Match data clobbered by buffer modification hooks"
 when hooks only shifted match-data's markers
Date: Fri, 02 Oct 2020 06:47:55 +0200
Noam Postavsky <npostavs <at> gmail.com> writes:

>> I think this is a variant of Bug#23917, there was some talk there about
>> removing the check, perhaps that is the right solution.
>
> So, this, I guess.

[...]

> * src/search.c (Freplace_match): Don't test for change in search_regs
> start and end, this is unreliable if change hooks modify text earlier
> in the buffer.

[...]

> -  if (search_regs.start[sub] != sub_start
> -      || search_regs.end[sub] != sub_end
> -      || search_regs.num_regs != num_regs)
> +  if (search_regs.num_regs != num_regs)
>      error ("Match data clobbered by buffer modification hooks");
>  
>    /* Put point back where it was in the text.  */

There were unfortunately no comments on this patch at the time.  Noam said:

> But the modification hook in question did call save-match-data.  As far
> as I can tell, the problem is that the match-data consists of markers,
> whose position gets shifted by deletion of characters.  The check for
> this error uses simple integers, so there's no way it can account for
> this.

That does make sense, but removing this (somewhat buggy) sanity check is
perhaps a bit scary.  Any comments on this?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 4 years and 2 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.