Subject: 29.0.50; overlays fail to evaporate across indirect buffers
From: Matt Armstrong <[email-masked]>
To: [email-masked]
Date: Tue, 01 Nov 2022 19:45:19 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

This bug is inspired by bug#58928, but not the same, and repros after
Stefan's fix for that bug.  In fact, it repros in Emacs 27 as well.

See attached patch for repro steps as an ert test.  Essentially, either:

1) Create an overlay in an indirect buffer, set its 'evaporate property
   to t.
2) Delete text from the base buffer such that the overlay is empty.
3) Verify it is no longer in the indirect buffer (in fact, it remains as
   an empty overlay).

Repeat the above swapping the indirect and base buffers.  The bug goes
both ways.

From 3da7e442467d5dad3c875d5bfb7e68017400a14b Mon Sep 17 00:00:00 2001
From: Matt Armstrong <[email-masked]>
Date: Tue, 1 Nov 2022 19:40:20 -0700
Subject: [PATCH] Add a test for overlay evaporation across indirect buffers

* test/src/buffer-tests.el (buffer-tests--overlays-indirect-evaporate):
Test evaporation of overlays triggered by deleting text in base
and in indirect buffers.  Test doesn't pass at the moment.
---
 test/src/buffer-tests.el | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index b96a8dcacd2..a4a1f609fd2 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -296,6 +296,42 @@ buffer-tests--overlays-indirect-bug58928
       (should (equal (overlay-start ol1) (overlay-start ol2)))
       (should (equal (overlay-end ol1) (overlay-end ol2))))))
 
+(ert-deftest buffer-tests--overlays-indirect-evaporate ()
+  "Verify that deleting text evaporates overlays in every related buffer.
+
+Deleting characters from either a base or an indirect buffer
+should evaporate overlays in both."
+  :expected-result :failed
+  ;; Loop twice, erasing from the base buffer the first time and the
+  ;; indirect buffer the second.
+  (dolist (erase-where '(base indirect))
+    (ert-info ((format "erase-where %S" erase-where))
+      (with-temp-buffer
+        (insert "xxx")
+        (let* ((beg 2)
+               (end 3)
+               (base (current-buffer))
+               (base-overlay (make-overlay beg end base))
+               (indirect (make-indirect-buffer
+                          base
+                          (generate-new-buffer-name
+                           (concat (buffer-name base) "-indirect"))))
+               (indirect-overlay (make-overlay beg end indirect)))
+          (overlay-put base-overlay 'evaporate t)
+          (overlay-put indirect-overlay 'evaporate t)
+          (with-current-buffer (pcase-exhaustive erase-where
+                                 (`base base)
+                                 (`indirect indirect))
+            (delete-region beg end))
+          (ert-info ((prin1-to-string
+                      `(,base ,base-overlay ,indirect ,indirect-overlay)))
+            (should (not (buffer-live-p (overlay-buffer base-overlay))))
+            (should (not (buffer-live-p (overlay-buffer indirect-overlay))))
+            (should (equal nil (with-current-buffer base
+                                 (overlays-in (point-min) (point-max)))))
+            (should (equal nil (with-current-buffer indirect
+                                 (overlays-in (point-min) (point-max)))))))))))
+
 (ert-deftest overlay-evaporation-after-killed-buffer ()
   (let* ((ols (with-temp-buffer
                 (insert "toto")
-- 
2.35.1

In GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version
 3.24.34, cairo version 1.16.0) of 2022-10-30 built on naz
Repository revision: 73953b23aad5af80275838cd3b1c88e045e1856e
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12201003
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure 'CFLAGS=-O2 -g3''

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

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: notmuch-show

Minor modes in effect:
  msb-mode: t
  display-time-mode: t
  global-tab-line-mode: t
  tab-line-mode: t
  envrc-global-mode: t
  envrc-mode: t
  shell-dirtrack-mode: t
  auto-insert-mode: t
  keyfreq-autosave-mode: t
  keyfreq-mode: t
  savehist-mode: t
  icomplete-vertical-mode: t
  icomplete-mode: t
  editorconfig-mode: t
  which-key-mode: t
  electric-pair-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  visual-line-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t

Load-path shadows:
~/env/elisp/ol-notmuch hides /home/matt/.config/emacs/elpa/ol-notmuch-20220428.1337/ol-notmuch
/home/matt/.config/emacs/elpa/transient-20221028.1430/transient hides /home/matt/git/e/daily-driver/lisp/transient

Features:
(shadow emacsbug cl-print pulse color display-line-numbers flymake-proc
flymake compile edebug ert ewoc debug backtrace mm-archive eudc-capf
eudc cus-edit cus-start cus-load eudc-vars apropos my timezone
bug-reference shortdoc ob-ditaa ob-plantuml org-clock org-colview
org-crypt org-plot help-fns radix-tree magit-base textsec uni-scripts
idna-mapping ucs-normalize uni-confusable textsec-check qp dabbrev sort
company-oddmuse company-keywords company-etags etags fileloop xref
company-gtags company-dabbrev-code company-dabbrev company-files
company-clang company-capf company-cmake company-semantic
company-template company-bbdb company copyright bookmark pp tabify
mail-extr org-capture shfmt reformatter sh-script executable vc-git
vc-dispatcher autorevert mule-util misearch multi-isearch notmuch
notmuch-tree notmuch-jump notmuch-hello notmuch-show notmuch-print
notmuch-crypto notmuch-mua notmuch-message notmuch-draft
notmuch-maildir-fcc notmuch-address notmuch-company notmuch-parser
notmuch-wash diff-mode coolj goto-addr icalendar diary-lib
diary-loaddefs notmuch-tag crm notmuch-lib notmuch-compat pcase hl-line
protbuf msb time flyspell ispell org-element avl-tree generator ol-w3m
ol-rmail ol-mhe ol-irc ol-info org-habit org-agenda org-refile ol-gnus
nnselect gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig
gnus-sum gnus-group gnus-undo gnus-start gnus-dbus dbus gnus-cloud
nnimap nnmail mail-source utf7 nnoo parse-time gnus-spec gnus-int
gnus-range message sendmail yank-media rfc822 mml mml-sec epa derived
epg rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231
rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus-win
ol-eww eww xdg url-queue shr pixel-fill kinsoku url-file svg xml dom
puny mm-url gnus nnheader gnus-util text-property-search mail-utils
range wid-edit mm-util mail-prsvr ol-doi org-link-doi ol-docview
doc-view filenotify jka-compr image-mode exif dired dired-loaddefs
ol-bibtex ol-bbdb tab-line server envrc inheritenv web-mode disp-table
nix-mode ffap thingatpt smie nix-repl nix-shell nix-store magit-section
dash compat-27 compat-26 nix-log nix-instantiate nix-shebang nix-format
nix dirtrack ob-shell shell ob-ruby ob-python python compat compat-macs
ob-dot org-protocol org ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint
ansi-osc ansi-color ring org-list org-faces org-entities noutline
outline org-version ob-emacs-lisp ob-core ob-eval org-table oc-basic
bibtex iso8601 time-date org-keys oc org-loaddefs find-func cal-menu
calendar cal-loaddefs finder-inf ol-notmuch ol rx org-compat org-macs
format-spec skeleton autoinsert advice keyfreq project edmacro kmacro
warnings icons savehist icomplete editorconfig editorconfig-core
editorconfig-core-handle editorconfig-fnmatch which-key package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers
url-parse auth-source eieio eieio-core password-cache json subr-x map
byte-opt url-vars cl-extra help-mode cl-macs gv cl-seq elec-pair
use-package use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key easy-mmode use-package-core cl-loaddefs
cl-lib bytecomp byte-compile info bazel-autoloads
clang-format+-autoloads clang-format-autoloads cmake-mode-autoloads
d-mode-autoloads debbugs-autoloads editorconfig-autoloads elpy-autoloads
company-autoloads envrc-autoloads exec-path-from-shell-autoloads
flymake-ruby-autoloads flymake-easy-autoloads flymake-yamllint-autoloads
go-mode-autoloads google-c-style-autoloads graphviz-dot-mode-autoloads
highlight-indentation-autoloads inheritenv-autoloads magit-autoloads
git-commit-autoloads markdown-mode-autoloads meson-mode-autoloads
nix-mode-autoloads magit-section-autoloads dash-autoloads
nixpkgs-fmt-autoloads ol-notmuch-autoloads notmuch-autoloads
orderless-autoloads org-drill-autoloads ox-hugo-autoloads
persist-autoloads pylint-autoloads pyvenv-autoloads s-autoloads
shfmt-autoloads reformatter-autoloads tomelr-autoloads
transient-autoloads use-package-autoloads bind-key-autoloads
vertico-autoloads web-mode-autoloads which-key-autoloads
with-editor-autoloads compat-autoloads yaml-mode-autoloads
yasnippet-autoloads rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process
emacs)

Memory information:
((conses 16 941521 83146)
 (symbols 48 39704 98)
 (strings 32 233884 11078)
 (string-bytes 1 6684537)
 (vectors 16 102158)
 (vector-slots 8 2025953 286858)
 (floats 8 543 603)
 (intervals 56 32489 598)
 (buffers 984 37))