unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#70824: 29.3; Run time error in `dabbrev-completion'
@ 2024-05-07 19:19 Matt Armstrong via Bug reports for GNU Emacs, the Swiss army knife of text editors
       [not found] ` <handler.70824.B.171510968110138.ack@debbugs.gnu.org>
  2024-05-25  7:34 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Matt Armstrong via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-07 19:19 UTC (permalink / raw)
  To: 70824

I'm in a state where `dabbrev--last-buffer' is set to #<killed buffer>,
which confuses the `dabbrev-completion' command as shown by the 
backtrace below.

If I find a way to reproduce I will follow up with that.

I suspect that dabbrev.el should use `(buffer-live-p
dabbrev--last-buffer)' instead of checking for non-nil.

First, the value of dabbrev--last-buffer:

     dabbrev--last-buffer is a variable defined in ‘dabbrev.el’.
     Its value is #<killed buffer>
     Not documented as a variable.

Second, what happens when I run `dabbrev-completion':

Debugger entered--Lisp error: (error "Selecting deleted buffer")
   set-buffer(#<killed buffer>)
   (progn (set-buffer dabbrev--last-buffer))
   (if dabbrev--last-buffer (progn (set-buffer dabbrev--last-buffer)))
   (save-excursion (if dabbrev--last-buffer (progn (set-buffer 
dabbrev--last-buffer))) (or (and (not dabbrev-search-these-buffers-only) 
(>= direction 0) (setq dabbrev--last-direction (min 1 direction)) 
(dabbrev--try-find abbrev t (max 1 direction) ignore-case)) (and (or 
(not dabbrev-search-these-buffers-only) dabbrev--last-buffer) (<= 
direction 0) (setq dabbrev--last-direction -1) (dabbrev--try-find abbrev 
nil (max 1 (- direction)) ignore-case)) (progn (setq 
dabbrev--last-direction -1) (if dabbrev--last-buffer nil (if 
dabbrev--friend-buffer-list nil (setq dabbrev--friend-buffer-list 
(dabbrev--make-friend-buffer-list)) (setq dabbrev--progress-reporter 
(make-progress-reporter "Scanning for dabbrevs..." (- ...) 0 0 1 1.5)))) 
(let ((file-name (buffer-file-name)) file-name-buffer) (unwind-protect 
(progn (if file-name (progn ... ... ...)) (let (expansion) (while ... 
... ... ... ... ...) (progress-reporter-done dabbrev--progress-reporter) 
expansion)) (if (buffer-live-p file-name-buffer) (progn (kill-buffer 
file-name-buffer))) (setq dabbrev--friend-buffer-list (seq-filter 
#'buffer-live-p dabbrev--friend-buffer-list)))))))
   dabbrev--find-expansion("p" -1 t)
   dabbrev--find-all-expansions("p" t)
   #f(compiled-function (s p a) #<bytecode -0x1773fde4def7ae30>)(#("p" 0 
1 (fontified t)) nil (boundaries . ""))
   completion-boundaries(#("p" 0 1 (fontified t)) #f(compiled-function 
(s p a) #<bytecode -0x1773fde4def7ae30>) nil "")
   completion-basic-try-completion(#("p" 0 1 (fontified t)) 
#f(compiled-function (s p a) #<bytecode -0x1773fde4def7ae30>) nil 1)
   #f(compiled-function (style) #<bytecode -0x1bb324416e7d7fbf>)(basic)
   completion--some(#f(compiled-function (style) #<bytecode 
-0x1bb324416e7d7fbf>) (basic partial-completion emacs22))
   completion--nth-completion(1 #("p" 0 1 (fontified t)) 
#f(compiled-function (s p a) #<bytecode -0x1773fde4def7ae30>) nil 1 
(metadata (cycle-sort-function . identity) (category . dabbrev)))
   completion-try-completion(#("p" 0 1 (fontified t)) 
#f(compiled-function (s p a) #<bytecode -0x1773fde4def7ae30>) nil 1 
(metadata (cycle-sort-function . identity) (category . dabbrev)))
   completion--do-completion(#<marker at 531 in persist.rs> 532)
   completion--in-region-1(#<marker at 531 in persist.rs> 532)
   #f(compiled-function (start end collection predicate) #<bytecode 
-0x16fb47f8fb6a4d3d>)(#<marker at 531 in persist.rs> 532 
#f(compiled-function (s p a) #<bytecode -0x1773fde4def7ae30>) nil)
   apply(#f(compiled-function (start end collection predicate) 
#<bytecode -0x16fb47f8fb6a4d3d>) (#<marker at 531 in persist.rs> 532 
#f(compiled-function (s p a) #<bytecode -0x1773fde4def7ae30>) nil))
   #f(compiled-function (funs global args) #<bytecode 
-0x73c1f01704730a2>)(nil nil (#<marker at 531 in persist.rs> 532 
#f(compiled-function (s p a) #<bytecode -0x1773fde4def7ae30>) nil))
   completion--in-region(#<marker at 531 in persist.rs> 532 
#f(compiled-function (s p a) #<bytecode -0x1773fde4def7ae30>) nil)
   completion-in-region(#<marker at 531 in persist.rs> 532 
#f(compiled-function (s p a) #<bytecode -0x1773fde4def7ae30>) nil)
   completion-at-point()
   dabbrev-completion(nil)
   funcall-interactively(dabbrev-completion nil)
   command-execute(dabbrev-completion)




In GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41,
cairo version 1.18.0)
System Description: Debian GNU/Linux 12 (bookworm)

Configured using:
  'configure
  --prefix=/nix/store/m88zm8z7qrby6zlnq32z35nmn89jdzkl-emacs-pgtk-29.3
  --disable-build-details --with-modules --with-pgtk
  --with-compress-install --with-toolkit-scroll-bars
  --with-native-compilation --without-imagemagick --without-small-ja-dic
  --with-tree-sitter --without-xinput2 --with-xwidgets --with-dbus
  --with-selinux'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER
PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM XWIDGETS GTK3 ZLIB

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

Major mode: ELisp/l

Minor modes in effect:
   global-git-commit-mode: t
   magit-auto-revert-mode: t
   shell-dirtrack-mode: t
   msb-mode: t
   display-time-mode: t
   flyspell-mode: t
   server-mode: t
   auto-insert-mode: t
   keyfreq-autosave-mode: t
   keyfreq-mode: t
   global-treesit-auto-mode: t
   savehist-mode: t
   vertico-mode: t
   editorconfig-mode: t
   which-key-mode: t
   electric-pair-mode: t
   override-global-mode: t
   tooltip-mode: t
   global-eldoc-mode: t
   eldoc-mode: t
   show-paren-mode: t
   electric-indent-mode: t
   mouse-wheel-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
   transient-mark-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   temp-buffer-resize-mode: t

Load-path shadows:
/home/matt/.nix-profile/share/emacs/site-lisp/cmake-mode hides 
/home/matt/.config/emacs/elpa/cmake-mode-3.28.1/cmake-mode
~/env/elisp/ol-notmuch hides 
/home/matt/.config/emacs/elpa/ol-notmuch-2.0.1/ol-notmuch
/nix/store/qm3ihp915s71a5sdvg6w7ag5vr295qmi-emacs-packages-deps/share/emacs/site-lisp/site-start 
hides 
/nix/store/m88zm8z7qrby6zlnq32z35nmn89jdzkl-emacs-pgtk-29.3/share/emacs/site-lisp/site-start
/home/matt/.config/emacs/elpa/project-0.10.0/project hides 
/nix/store/m88zm8z7qrby6zlnq32z35nmn89jdzkl-emacs-pgtk-29.3/share/emacs/29.3/lisp/progmodes/project

Features:
(shadow sort mail-extr emacsbug jka-compr cl-print cus-start cus-load
shortdoc dabbrev vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs
log-view vc bug-reference magit-extras face-remap magit-submodule
magit-obsolete magit-blame magit-stash magit-reflog magit-bisect
magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit
magit-sequence magit-notes magit-worktree magit-tag magit-merge
magit-branch magit-reset magit-files magit-refs magit-status magit
magit-repos magit-apply magit-wip magit-log which-func magit-diff
smerge-mode diff git-commit log-edit message sendmail yank-media puny
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader
pcvs-util add-log magit-core magit-autorevert autorevert magit-margin
magit-transient magit-process with-editor dirtrack shell pcomplete
magit-mode magit-git magit-section magit-utils crm dash files-x
find-dired dired dired-loaddefs grep pulse yasnippet protbuf msb time
markdown-mode color noutline outline go-mode find-file ffap eglot
external-completion array filenotify jsonrpc ert pp ewoc debug backtrace
flymake-proc flymake imenu copyright misearch multi-isearch time-date
vc-git diff-mode vc-dispatcher rust-ts-mode c-ts-common flyspell ispell
midnight server geiser-guile info-look transient format-spec
geiser-debug geiser-repl geiser-image geiser-capf geiser-doc geiser-menu
geiser-autodoc geiser-edit etags fileloop generator xref
geiser-completion geiser-eval geiser-connection tq geiser-syntax scheme
geiser-impl help-fns radix-tree geiser-log geiser-popup view
geiser-custom geiser-base geiser skeleton autoinsert advice keyfreq
rust-utils thingatpt rust-mode rust-rustfmt rust-playpen rust-compile
compile text-property-search comint ansi-osc ansi-color ring rust-cargo
project codeium treesit-auto treesit edmacro kmacro savehist corfu
vertico compat compat-29 comp comp-cstr warnings icons rx editorconfig
editorconfig-core editorconfig-core-handle editorconfig-fnmatch pcase
modus-operandi-theme modus-themes 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-macs gv cl-extra help-mode 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 find-func info cmake-mode-autoloads
codeium-autoloads corfu-autoloads debbugs-autoloads company-autoloads
geiser-guile-autoloads geiser-autoloads god-mode-autoloads
meow-autoloads modus-themes-autoloads nix-mode-autoloads
nixpkgs-fmt-autoloads notmuch-autoloads rust-mode-autoloads
reformatter-autoloads treesit-auto-autoloads vertico-autoloads
web-mode-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/pgtk-win pgtk-win
term/common-win pgtk-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 xwidget-internal dbusbind inotify dynamic-setting
system-font-setting font-render-setting cairo gtk pgtk multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 449923 81499)
  (symbols 48 28929 27)
  (strings 32 104412 4026)
  (string-bytes 1 3615216)
  (vectors 16 65301)
  (vector-slots 8 1514110 53758)
  (floats 8 396 470)
  (intervals 56 4575 36)
  (buffers 984 32))






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#70824: 29.3; Run time error in `dabbrev-completion'
       [not found] ` <handler.70824.B.171510968110138.ack@debbugs.gnu.org>
@ 2024-05-07 19:52   ` Matt Armstrong via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-05-08 13:24     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Armstrong via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-07 19:52 UTC (permalink / raw)
  To: 70824

Debugging this further (sorry, still no repro so I'm debugging my live 
image), I think this was introduced a few years ago in commit 
2d0085f756572856a2ed8d1bf043b59195a3e3f3 and partially fixed in commit 
d0975d7db03c231a3db5a1cd0edaf41094d43f0d.

Those commits introduced a feature where `dabbrev--find-expansion' 
considers the components of a buffer's file name as completion 
candidates. It does this by creating a temp buffer containing the 
components.

The problem is that this temp buffer is immediately killed, yet dabbrev 
variables still hold references to it. The second commit above correctly 
removes the killed buffer from `dabbrev--friend-buffer-list', but did 
not handle the case where `dabbrev--last-buffer' or 
`dabbrev--last-buffer-found' happened to be the just-killed buffer.

I can think of two approaches:

  - continual with the "manual GC" approach and scrub more dabbrev vars 
of this killed buffer.
  - handle the killed buffer gracefully by using buffer-live-p 
consistently, instead using checks against nil.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#70824: 29.3; Run time error in `dabbrev-completion'
  2024-05-07 19:52   ` Matt Armstrong via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-05-08 13:24     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2024-05-08 13:24 UTC (permalink / raw)
  To: Matt Armstrong; +Cc: 70824

> Date: Tue, 7 May 2024 12:52:56 -0700
> From:  Matt Armstrong via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Debugging this further (sorry, still no repro so I'm debugging my live 
> image), I think this was introduced a few years ago in commit 
> 2d0085f756572856a2ed8d1bf043b59195a3e3f3 and partially fixed in commit 
> d0975d7db03c231a3db5a1cd0edaf41094d43f0d.
> 
> Those commits introduced a feature where `dabbrev--find-expansion' 
> considers the components of a buffer's file name as completion 
> candidates. It does this by creating a temp buffer containing the 
> components.
> 
> The problem is that this temp buffer is immediately killed, yet dabbrev 
> variables still hold references to it. The second commit above correctly 
> removes the killed buffer from `dabbrev--friend-buffer-list', but did 
> not handle the case where `dabbrev--last-buffer' or 
> `dabbrev--last-buffer-found' happened to be the just-killed buffer.

Thanks for the analysis.

> I can think of two approaches:
> 
>   - continual with the "manual GC" approach and scrub more dabbrev vars 
> of this killed buffer.
>   - handle the killed buffer gracefully by using buffer-live-p 
> consistently, instead using checks against nil.

I think we should do both.

Can you suggest a patch along these lines?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#70824: 29.3; Run time error in `dabbrev-completion'
  2024-05-07 19:19 bug#70824: 29.3; Run time error in `dabbrev-completion' Matt Armstrong via Bug reports for GNU Emacs, the Swiss army knife of text editors
       [not found] ` <handler.70824.B.171510968110138.ack@debbugs.gnu.org>
@ 2024-05-25  7:34 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2024-05-25  7:34 UTC (permalink / raw)
  To: Matt Armstrong; +Cc: 70824-done

> Date: Tue, 7 May 2024 12:19:43 -0700
> From:  Matt Armstrong via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> I'm in a state where `dabbrev--last-buffer' is set to #<killed buffer>,
> which confuses the `dabbrev-completion' command as shown by the 
> backtrace below.
> 
> If I find a way to reproduce I will follow up with that.
> 
> I suspect that dabbrev.el should use `(buffer-live-p
> dabbrev--last-buffer)' instead of checking for non-nil.

Thanks, I added the buffer-live-p tests where appropriate in
dabbrev.el and installed the changes on the master branch.  I'm now
boldly closing this bug.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-25  7:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-07 19:19 bug#70824: 29.3; Run time error in `dabbrev-completion' Matt Armstrong via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found] ` <handler.70824.B.171510968110138.ack@debbugs.gnu.org>
2024-05-07 19:52   ` Matt Armstrong via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-08 13:24     ` Eli Zaretskii
2024-05-25  7:34 ` Eli Zaretskii

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).