GNU bug report logs - #62474
29.0.60; wrong-type-argument from pcomplete-opt

Previous Next

Package: emacs;

Reported by: "J.P." <jp <at> neverwas.me>

Date: Mon, 27 Mar 2023 02:13:02 UTC

Severity: normal

Found in version 29.0.60

Done: "J.P." <jp <at> neverwas.me>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62474 in the body.
You can then email your comments to 62474 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to gregory <at> heytings.org, bug-gnu-emacs <at> gnu.org:
bug#62474; Package emacs. (Mon, 27 Mar 2023 02:13:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "J.P." <jp <at> neverwas.me>:
New bug report received and forwarded. Copy sent to gregory <at> heytings.org, bug-gnu-emacs <at> gnu.org. (Mon, 27 Mar 2023 02:13:02 GMT) Full text and rfc822 format available.

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

From: "J.P." <jp <at> neverwas.me>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.60; wrong-type-argument from pcomplete-opt
Date: Sun, 26 Mar 2023 19:08:00 -0700
Hi, this may be related to (or a duplicate of):

  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59750

I first encountered it in ERC, but it appears to happen from any
pcomplete/foo function that calls `pcomplete-opt' with a string of
length two or more. AFAICT, this doesn't occur in Emacs 28.

Example from emacs -Q:

  1. M-x eshell
  2. type "gzip -" and hit TAB
  3. type "h" -> wrong-type-argument // "h" gets inserted anyway
  4. type TAB -> wrong-type-argument

  ~/emacs/emacs-29 gzip -{h}
  Error in post-command-hook (completion-in-region--postch):
  (wrong-type-argument integer-or-marker-p nil)
  
  ~/emacs/emacs-29 gzip -h{tab}
  Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
    pcomplete-arg()
    pcomplete-opt("cdfhlLnNqrStvV123456789")
    pcomplete/gzip()
    pcomplete-completions()
    pcomplete-completions-at-point()
    completion--capf-wrapper(pcomplete-completions-at-point all)
    run-hook-wrapped(completion--capf-wrapper pcomplete-completions-at-point all)
    completion-at-point()
    funcall-interactively(completion-at-point)
    call-interactively(completion-at-point nil nil)
    command-execute(completion-at-point)

The backtrace for `pcomplete/erc-mode/DCC' is basically identical to the
one above. But stepping through it manually reveals:

  (buffer-substring (pcomplete-begin index offset) (point))
  pcomplete-actual-arg(nil nil)
  (split-string (pcomplete-actual-arg index offset))
  (car (split-string (pcomplete-actual-arg index offset)))
  (propertize (car (split-string (pcomplete-actual-arg index offset))) 'pcomplete-arg-value arg)
  (if (or (stringp arg) (eq index 'last)) arg (...))
  (let ((arg (nth (+ (let* ((val index)) (...)) (or offset 0)) pcomplete-args))) (...))
  pcomplete-arg()
  (setq pcomplete-stub (pcomplete-arg))
  (progn (setq pcomplete-index (1+ pcomplete-index)) (setq pcomplete-stub (pcomplete-arg)))
  pcomplete-next-arg()
  (progn (pcomplete-next-arg) ...)
  (if (and (> (length arg) 1) (stringp arg) (eq (aref arg 0) (or prefix 45))) (...))
  (let ((arg (pcomplete-arg))) (...))
  (if (and (= pcomplete-index pcomplete-last) (string= (pcomplete-arg) "-")) (...))
  pcomplete-opt("ts")
  pcomplete/erc-mode/DCC()
  pcomplete-completions()
  pcomplete-completions-at-point()
  erc-pcompletions-at-point()
  run-hook-with-args-until-success(erc-pcompletions-at-point)
  erc-complete-word-at-point()
  completion--capf-wrapper(erc-complete-word-at-point all)
  run-hook-wrapped(completion--capf-wrapper erc-complete-word-at-point all)
  completion-at-point()
  funcall-interactively(completion-at-point)
  call-interactively(completion-at-point nil nil)
  command-execute(completion-at-point)

I don't know enough about pcomplete to have an opinion here, but I did
notice two quite similar out-of-range `nth' accesses, which may be
unrelated or useless:

  1. In `pcomplete-arg', `pcomplete-index' equals the length of
     `pcomplete-args', resulting in `nth' always returning nil.

  2. In the offending pcomplete-begin(nil nil) -> nil, `index' becomes 3
     (courtesy of `pcomplete-index'), which is also the length of
     `pcomplete-begins'.

I've copied in Gregory Heytings, who has relatively recent commits
in this general vicinity. Thanks.


In GNU Emacs 29.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.35, cairo version 1.17.6) of 2023-03-26 built on localhost

Configured using:
 'configure --enable-check-lisp-object-type --enable-checking=yes,glyphs
 'CFLAGS=-O0 -g3'
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

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 WEBP 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: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-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
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils 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 36151 10267)
 (symbols 48 5152 0)
 (strings 32 13131 2059)
 (string-bytes 1 374002)
 (vectors 16 9322)
 (vector-slots 8 148973 14280)
 (floats 8 21 26)
 (intervals 56 220 0)
 (buffers 976 10))




Reply sent to "J.P." <jp <at> neverwas.me>:
You have taken responsibility. (Thu, 18 Jan 2024 23:20:02 GMT) Full text and rfc822 format available.

Notification sent to "J.P." <jp <at> neverwas.me>:
bug acknowledged by developer. (Thu, 18 Jan 2024 23:20:02 GMT) Full text and rfc822 format available.

Message #10 received at 62474-done <at> debbugs.gnu.org (full text, mbox):

From: "J.P." <jp <at> neverwas.me>
To: 62474-done <at> debbugs.gnu.org
Subject: Re: bug#62474: 29.0.60; wrong-type-argument from pcomplete-opt
Date: Thu, 18 Jan 2024 15:18:42 -0800
"J.P." <jp <at> neverwas.me> writes:

> Hi, this may be related to (or a duplicate of):
>
>   https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59750
>
> I first encountered it in ERC, but it appears to happen from any
> pcomplete/foo function that calls `pcomplete-opt' with a string of
> length two or more. AFAICT, this doesn't occur in Emacs 28.
>
> Example from emacs -Q:
>
>   1. M-x eshell
>   2. type "gzip -" and hit TAB
>   3. type "h" -> wrong-type-argument // "h" gets inserted anyway
>   4. type TAB -> wrong-type-argument

This appears to have been fixed by

  239db5d5162f6f9a4a6735e176c8d306f18e50e7
  Author:     Jim Porter <jporterbugs <at> gmail.com>
  AuthorDate: Tue Sep 5 18:27:21 2023 -0700
  Commit:     Jim Porter <jporterbugs <at> gmail.com>
  CommitDate: Tue Oct 10 13:00:38 2023 -0700
  
  Follows:    emacs-29.1 (168549)
  
  Revert commits dafa6d6badd6 and 72c45fa9109a
  
  These were there to work around deficiencies in how Eshell produces
  completions for 'pcomplete-argument' (Eshell passed various non-string
  objects to Pcomplete, which broke things).  Now, Eshell always returns
  a stringified form of the argument, with the original value stored via
  the text property 'pcomplete-arg-value'.
  
  * lisp/pcomplete.el (pcomplete-arg): Revert changes back to a simpler
  form.
  
  1 file changed, 7 insertions(+), 29 deletions(-)
  lisp/pcomplete.el | 36 +++++++-----------------------------

Closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 16 Feb 2024 12:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 62 days ago.

Previous Next


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