GNU bug report logs - #52798
27.2; `undo' causes `buffer-undo-list' to grow exponentially

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Vladimir Panteleev <vladimir.panteleev.md@HIDDEN>; Keywords: confirmed; dated Sun, 26 Dec 2021 01:31:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) confirmed. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 52798 <at> debbugs.gnu.org:


Received: (at 52798) by debbugs.gnu.org; 29 Dec 2021 16:29:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Dec 29 11:29:39 2021
Received: from localhost ([127.0.0.1]:50081 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1n2bpb-0008TC-2n
	for submit <at> debbugs.gnu.org; Wed, 29 Dec 2021 11:29:39 -0500
Received: from quimby.gnus.org ([95.216.78.240]:43518)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1n2bpY-0008Sv-V6
 for 52798 <at> debbugs.gnu.org; Wed, 29 Dec 2021 11:29:37 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=7/JPvC4SIg7LeEyOSSPLXkfU2eKlbSSEvIsuDIypxus=; b=k0t0ESPygOgCSrhQ9+uwAsWw3e
 A5v4RhfGkBE5yPh7R4yRnJgKp2fw+0r15P7dh4B47Phy6RbLN0XAFOGM1mbiqiAoFyDJ8UmYZe59C
 iGwSFKbNbscNRCq5b6a6Cji2PXf86cmOBlY0F7euiI/40NX851Z449IDYogdY0B1Cva4=;
Received: from [84.212.220.105] (helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1n2bpP-0007al-9j; Wed, 29 Dec 2021 17:29:29 +0100
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Vladimir Panteleev <vladimir.panteleev.md@HIDDEN>
Subject: Re: bug#52798: 27.2; `undo' causes `buffer-undo-list' to grow
 exponentially
References: <CAHhfkvxmNaOHEi_P5Lww-NmxEj1+xS0HtfnT1S9ue6SO+6yy7g@HIDDEN>
X-Now-Playing: Hot Chip's _Coming on Strong_: "Take Care"
Date: Wed, 29 Dec 2021 17:29:26 +0100
In-Reply-To: <CAHhfkvxmNaOHEi_P5Lww-NmxEj1+xS0HtfnT1S9ue6SO+6yy7g@HIDDEN>
 (Vladimir Panteleev's message of "Sun, 26 Dec 2021 00:59:59 +0000")
Message-ID: <87k0fn4bo9.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Vladimir Panteleev <vladimir.panteleev.md@HIDDEN> writes:
 > As far as I can see,
 the undo (and undo-only) command causes > buffer-undo-list
 to grow exponentially. This causes information about > previous entries to
 eventually be displaced. 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 52798
Cc: 52798 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Vladimir Panteleev <vladimir.panteleev.md@HIDDEN> writes:

> As far as I can see, the undo (and undo-only) command causes
> buffer-undo-list to grow exponentially. This causes information about
> previous entries to eventually be displaced.

I can reproduce this in Emacs 29, too.  Perhaps Stefan has some
comments; added to the CCs.

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




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#52798; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Dec 2021 01:30:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 25 20:30:46 2021
Received: from localhost ([127.0.0.1]:40069 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1n1IN2-0005BV-8i
	for submit <at> debbugs.gnu.org; Sat, 25 Dec 2021 20:30:46 -0500
Received: from lists.gnu.org ([209.51.188.17]:45778)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <thecybershadow@HIDDEN>) id 1n1Htn-0004KQ-DB
 for submit <at> debbugs.gnu.org; Sat, 25 Dec 2021 20:00:32 -0500
Received: from eggs.gnu.org ([209.51.188.92]:33232)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <thecybershadow@HIDDEN>)
 id 1n1Htk-0001Xk-PE
 for bug-gnu-emacs@HIDDEN; Sat, 25 Dec 2021 20:00:29 -0500
Received: from [2607:f8b0:4864:20::934] (port=44597
 helo=mail-ua1-x934.google.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <thecybershadow@HIDDEN>)
 id 1n1Htf-0002fc-IU
 for bug-gnu-emacs@HIDDEN; Sat, 25 Dec 2021 20:00:26 -0500
Received: by mail-ua1-x934.google.com with SMTP id p2so20718022uad.11
 for <bug-gnu-emacs@HIDDEN>; Sat, 25 Dec 2021 17:00:16 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:from:date:message-id:subject:to;
 bh=d+zON15S98ZuBXQ5qLsrfYGePnH3pySN9jDOrmbIGik=;
 b=l0O+zmrlnr3hiMutrzGBhqhDzUFjLXTkqJXMxReQrr9+tqVQQa5giqRBcmTIGiWDqv
 O62IlQn+FLe/h+3R1O4Cn4tP38yUmSujhVpN++Txb3dM0SNF+EPAbAQ7ihqE8xu7KRfA
 I3NBJj+6xEvh/CkZYJ6b3LD89VEtoBqiFuzpy/Z5ePkZOrMCkusloC77Qot+zio/GY5V
 N5PYJf0PzaQK0D3CSqORU4Dh4V5S2e/OW78qIH9O1AM7YSDvpHxR626C039iiZvCvmcS
 6rbG5KPisINM8UHTRT47HFVPt5DacLNrtk3zxvH0bC0I9/MRCNgnHDtnvPxmFalDsrsb
 QwdQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=d+zON15S98ZuBXQ5qLsrfYGePnH3pySN9jDOrmbIGik=;
 b=ezhNjJDccuMYuv8iQ9JHD4++wUYDK2TtGv16j4VDLXrPgmX+KXsgCXSqurM8MzUYuU
 M8aBDeOYwXLVyA4VFz6EtfdncXSri5/fG/hemR3RZ6AmgCdnXvjZ4NUKdC+9V84JX77D
 K513y0O9NVIfWHmAIxRE+p+/T4qrEXzO2fzALzeh1Bf0RYCOfNYtv63j9m3LFRybAiFT
 UbgGwGP9/TTbPxlxe9dFHAtm0cbuS/H50yOAft6IMANm/WCW01BqfiS1RpxpUj8/N7lu
 p4EBpOazuJY7RO7m6Z9znDAvuXRRNi7L8QRvA5SqrFm5gJCX19xHzHa4oaW4dm5KOHYu
 K5Vw==
X-Gm-Message-State: AOAM531kkY6Qxkxr3sbE1yODcLjJMl9zUQoUSOYuOOgKcL0L0joEkXLo
 tysqGyB75ooVnNnnnLOor3+RuuvBQ3lcq7Dq3OCy+QujzeMTfDyW
X-Google-Smtp-Source: ABdhPJxHtHnKQ/vv4yTdWZvYh+zK3U04bXYJ5aozik1GHIfZlynvl5hL9mu89R1q9CsgdvhJpM8WFKGtYvIrmIZJ+E8=
X-Received: by 2002:ab0:3117:: with SMTP id e23mr3472631ual.38.1640480415390; 
 Sat, 25 Dec 2021 17:00:15 -0800 (PST)
MIME-Version: 1.0
From: Vladimir Panteleev <vladimir.panteleev.md@HIDDEN>
Date: Sun, 26 Dec 2021 00:59:59 +0000
Message-ID: <CAHhfkvxmNaOHEi_P5Lww-NmxEj1+xS0HtfnT1S9ue6SO+6yy7g@HIDDEN>
Subject: 27.2; `undo' causes `buffer-undo-list' to grow exponentially
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::934
 (failed)
Received-SPF: pass client-ip=2607:f8b0:4864:20::934;
 envelope-from=thecybershadow@HIDDEN; helo=mail-ua1-x934.google.com
X-Spam_score_int: 17
X-Spam_score: 1.7
X-Spam_bar: +
X-Spam_report: (1.7 / 5.0 requ) AC_FROM_MANY_DOTS=2.999, BAYES_00=-1.9,
 DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 25 Dec 2021 20:30:42 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Consider this Emacs Lisp script:

---
(eval-when-compile
  (require 'cl-lib))

(with-current-buffer (get-buffer-create "undo-test")
  ;; First, insert 50 characters.
  ;; Place an undo boundary after every insertion.
  (cl-loop repeat 50 do
       (insert "x")
       (undo-boundary))

  ;; Then, undo 50 times.
  ;; It doesn't matter if we use undo or undo-only.
  ;; We will only get into about 12 undos,
  ;; before the new exponentially-growing entries erase the old history.
  (cl-loop repeat 50 do
       (undo-only)
       (message "Length is now: %S" (length buffer-undo-list))))
---

When executed with `emacs --script test.el', I see the following output:

---
Undo
Length is now: 102
Undo
Length is now: 104
Undo
Length is now: 108
Undo
Length is now: 116
Undo
Length is now: 132
Undo
Length is now: 164
Undo
Length is now: 228
Undo
Length is now: 356
Undo
Length is now: 612
Undo
Length is now: 1124
Undo
Length is now: 2148
Undo
Length is now: 4196
Undo
Length is now: 8292
No further undo information
---

As far as I can see, the undo (and undo-only) command causes
buffer-undo-list to grow exponentially. This causes information about
previous entries to eventually be displaced.

N.B.: I noticed that upping gc-cons-threshold lets it do more undos, but
it does not prevent the exponential growth issue.

I think this is a bug by itself, but it's worth mentioning that this
script is a reduced version of a different problem I'm seeing with the
"No further undo information" message; the bug described here may or may
not be the root cause of that bug.

In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27,
cairo version 1.17.4)
 of 2021-03-26 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.12101002
System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-wide-int
 --with-modules --with-cairo --with-harfbuzz 'CFLAGS=-march=x86-64
 -mtune=generic -O2 -pipe -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON
PDUMPER LCMS2 GMP

Important settings:
  value of $LC_TIME: en_DK.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix




Acknowledgement sent to Vladimir Panteleev <vladimir.panteleev.md@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#52798; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 29 Dec 2021 16:45:01 UTC

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