GNU bug report logs - #70122
29.3.50; transpose-regions can crash Emacs

Previous Next

Package: emacs;

Reported by: Braun Gábor <braungb88 <at> gmail.com>

Date: Mon, 1 Apr 2024 10:04:02 UTC

Severity: normal

Tags: patch, pending

Found in version 29.3.50

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Braun Gábor <braungb88 <at> gmail.com>
Cc: 70122 <at> debbugs.gnu.org
Subject: bug#70122: 29.3.50; transpose-regions can crash Emacs
Date: Sat, 20 Apr 2024 10:50:35 +0300
> From: Braun Gábor <braungb88 <at> gmail.com>
> Cc: 70122 <at> debbugs.gnu.org
> Date: Tue, 16 Apr 2024 16:26:46 +0200
> 
> Hi Eli,
> 
> > > The issue I was unable to solve is that the functions
> > > set_text_properties_1 and graft_intervals_into_buffer
> > > record text property changes in undo history, but this is 
> unwanted
> > > here as transpose-regions handles undo history itself.
> ...
> > 
> > But this is not a new problem, right?  The code called
> > set_text_properties_1 and graft_intervals_into_buffer before the
> > changes as well, and had the same effect on undo history.  
> Right?
> > 
> > If this is something caused by these changes, could you please 
> explain
> > the issue in more detail, with references to the relevant parts 
> of the
> > code?
> 
> I don't think it is a new problem, and the other branches have the 
> same problem.
> 
> In detail, in all branches transpose-regions adds the undo entries 
> early for its changes (calls to record_change),
> then during making the changes already recorded in undo history
> calls functions adding additional undo entries 
> (set_text_properties_1, graft_intervals_into_buffer),
> i.e. at a time when the buffer state and undo history does not 
> match.  Luckily these entries are text property changes to a text 
> deleted immediately by the following entries, so their effects are 
> not visible, but this is due to the initial undo entries
> recording change to a larger span of text than just the two 
> swapped regions.
> 
> When not just the byte length but the character length of the 
> swapped regions are the same, the original code didn't change text 
> properties between the two regions, i.e., the text property 
> changes were restricted to the swapped regions, and hence
> restricting the initial undo entries to these region worked.
> 
> The new changes do make text property changes to the text between 
> the swapped regions additionally (as interval positions need 
> adjustment), which makes it harder for the undo entries,
> and that's why I did what the other branches do.
> 
> 
> All in all, the issue is not about correctness of code, but rather 
> cleanness of code: separate responsibilities: which part of the 
> code is responsible for (which) undo entries.

Did you receive the copyright assignment form, and if so, did you fill
and email it according to instructions?  I'm waiting for the
assignment paperwork to come to completion before installing these
changes.




This bug report was last modified 61 days ago.

Previous Next


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