GNU bug report logs - #12677
24.2.50; `nreverse' complains that ("foo") is not `listp'

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Thu, 18 Oct 2012 19:28:01 UTC

Severity: normal

Found in version 24.2.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

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 12677 in the body.
You can then email your comments to 12677 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 bug-gnu-emacs <at> gnu.org:
bug#12677; Package emacs. (Thu, 18 Oct 2012 19:28:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Drew Adams" <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 18 Oct 2012 19:28:02 GMT) Full text and rfc822 format available.

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

From: "Drew Adams" <drew.adams <at> oracle.com>
To: <bug-gnu-emacs <at> gnu.org>
Subject: 24.2.50; `nreverse' complains that ("foo") is not `listp'
Date: Thu, 18 Oct 2012 12:25:16 -0700
I do not understand this, and I haven't found a way to repro it from
emacs -Q.  (I can give a much longer recipe, but I doubt you are
interested.)
 
Here is the backtrace.  The first line makes it clear that the list
("c:/drews-lisp-20/CONTRIB/") is not considered `listp'.  But if you
just start with (setq dir-names '("c:/drews-lisp-20/CONTRIB/")) there is
no problem.  Yet `e dir-names' shows that that is the value.  And `e
(listp dir-names)' returns t.  Bizarre.  Dunno whether this report will
help in any way, but this debugger behavior sure seems odd.
 
Debugger entered--Lisp error: (wrong-type-argument listp ("c:/drews-lisp-20=
/CONTRIB/"))
  nreverse(("c:/drews-lisp-20/CONTRIB/"))
  (setq dir-names (nreverse (delete "" dir-names)))
  (prog1 (setq dir-names (nreverse (delete "" dir-names))) (icicle-unbind-f=
ile-candidate-keys) (if (interactive-p) (progn (message "Directories: %S" d=
ir-names))))
  (let* ((icicle-orig-buff (current-buffer)) (icicle-orig-window (selected-=
window)) (prompt (or icicle-prompt "Choose directory (`RET' when done): "))=
 (dir-names nil) (icicle-proxy-candidates (let ((ipc nil)) (if icicle-add-p=
roxy-candidates-flag (progn (setq ipc (icicle-remove-if-not ... ...) ipc (a=
pply ... ipc) ipc (icicle-remove-if-not ... ipc)))) ipc)) (user-file-pred i=
cicle-file-predicate) (icicle-file-predicate (if user-file-pred (function (=
lambda (f) (and (file-directory-p f) (funcall user-file-pred f)))) (functio=
n file-directory-p))) (icicle-comp-base-is-default-dir-p t) (completion-ign=
ore-case (or (and (boundp (quote read-file-name-completion-ignore-case)) re=
ad-file-name-completion-ignore-case) completion-ignore-case)) (icicle-show-=
Completions-initially-flag (or icicle-show-Completions-initially-flag icicl=
e-files-ido-like-flag)) (icicle-top-level-when-sole-completion-flag (or ici=
cle-top-level-when-sole-completion-flag icicle-files-ido-like-flag)) (icicl=
e-default-value (if (and icicle-files-ido-like-flag icicle-default-value) i=
cicle-files-ido-like-flag (and (memq icicle-default-value (quote (t nil))) =
icicle-default-value))) (icicle-must-match-regexp icicle-file-match-regexp)=
 (icicle-must-not-match-regexp icicle-file-no-match-regexp) (icicle-must-pa=
ss-after-match-predicate icicle-file-predicate) (icicle-require-match-flag =
icicle-file-require-match-flag) (icicle-extra-candidates icicle-file-extras=
) (icicle-transform-function (quote icicle-remove-dups-if-extras)) (icicle-=
-temp-orders (copy-sequence icicle-sort-orders-alist)) (icicle-sort-orders-=
alist (progn (if (and icicle-file-sort-first-time-p icicle-file-sort) (prog=
n (setq icicle-sort-comparer icicle-file-sort icicle-file-sort-first-time-p=
 nil))) (if icicle-file-sort (let ((already-there ...)) (if already-there (=
cons already-there ...) (cons ... icicle--temp-orders))) icicle--temp-order=
s))) (icicle-candidate-help-fn (function (lambda (cand) (icicle-describe-fi=
le cand current-prefix-arg t)))) (icicle-candidate-alt-action-fn (or icicle=
-candidate-alt-action-fn (icicle-alt-act-fn-for-type "file"))) (icicle-all-=
candidates-list-alt-action-fn (or icicle-all-candidates-list-alt-action-fn =
(icicle-alt-act-fn-for-type "file"))) (icicle-delete-candidate-object (quot=
e icicle-delete-file-or-directory)) (icicle-candidate-action-fn (function (=
lambda (candidate) (let ((minibuffer-completion-table minibuffer-completion=
-table) (minibuffer-completion-predicate minibuffer-completion-predicate) (=
minibuffer-completion-confirm minibuffer-completion-confirm) (minibuffer-co=
mpleting-file-name minibuffer-completing-file-name) (minibuffer-completing-=
symbol ...) (minibuffer-exit-hook minibuffer-exit-hook) (minibuffer-help-fo=
rm minibuffer-help-form) (minibuffer-history-variable minibuffer-history-va=
riable) (minibuffer-history-case-insensitive-variables minibuffer-history-c=
ase-insensitive-variables) (minibuffer-history-sexp-flag minibuffer-history=
-sexp-flag) (minibuffer-message-timeout ...) (minibuffer-prompt-properties =
...) (minibuffer-setup-hook minibuffer-setup-hook) (minibuffer-text-before-=
history minibuffer-text-before-history)) (setq candidate (expand-file-name =
candidate ...)) (let (...) (cond ... ... ... ...)) (select-window (minibuff=
er-window)) (select-frame-set-input-focus (selected-frame)) nil))))) (icicl=
e-bind-file-candidate-keys) (let ((body (function (lambda nil (let (...) (s=
etq icicle-candidate-action-fn nil) (funcall ... file-choice)))))) (cond ((=
and debug-on-error debug-on-quit) (condition-case act-on-choice (funcall bo=
dy))) (debug-on-error (condition-case act-on-choice (funcall body) (quit (i=
cicle-try-switch-buffer icicle-orig-buff) nil))) (debug-on-quit (condition-=
case act-on-choice (funcall body) (error (icicle-try-switch-buffer icicle-o=
rig-buff) nil (error "%s" (error-message-string act-on-choice))))) (t (cond=
ition-case act-on-choice (funcall body) (quit (icicle-try-switch-buffer ici=
cle-orig-buff) nil) (error (icicle-try-switch-buffer icicle-orig-buff) nil =
(error "%s" (error-message-string act-on-choice))))))) (prog1 (setq dir-nam=
es (nreverse (delete "" dir-names))) (icicle-unbind-file-candidate-keys) (i=
f (interactive-p) (progn (message "Directories: %S" dir-names)))))
  icicle-directory-list()
  call-interactively(icicle-directory-list record-it)
  icicle-execute-extended-command-1("icicle-directory-list")
  #[...] 9]()
  funcall(#[...] 9])
  icicle-execute-extended-command()
  call-interactively(icicle-execute-extended-command nil nil)
 
In GNU Emacs 24.2.50.1 (i386-mingw-nt5.1.2600)
 of 2012-10-15 on DANI-PC
Bzr revision: 110553 monnier <at> iro.umontreal.ca-20121015164957-6zms5w2js1xkld=
tg
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
 `configure --with-gcc (4.7) --no-opt --enable-checking --cflags
 -I../../libs/libxpm-3.5.8/include -I../../libs/libxpm-3.5.8/src
 -I../../libs/libpng-1.4.10 -I../../libs/zlib-1.2.6
 -I../../libs/giflib-4.1.4-1/include -I../../libs/jpeg-6b-4/include
 -I../../libs/tiff-3.8.2-1/include
 -I../../libs/libxml2-2.7.8-w32-bin/include/libxml2
 -I../../libs/gnutls-3.0.16/include
 -I../../libs/libiconv-1.14-2-mingw32-dev/include'
 





Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Fri, 19 Oct 2012 00:58:01 GMT) Full text and rfc822 format available.

Notification sent to "Drew Adams" <drew.adams <at> oracle.com>:
bug acknowledged by developer. (Fri, 19 Oct 2012 00:58:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: "Drew Adams" <drew.adams <at> oracle.com>
Cc: 12677-done <at> debbugs.gnu.org
Subject: Re: bug#12677: 24.2.50;
	`nreverse' complains that ("foo") is not `listp'
Date: Thu, 18 Oct 2012 20:55:47 -0400
> Debugger entered--Lisp error: (wrong-type-argument listp ("c:/drews-lisp-20=
> /CONTRIB/"))

My guess is that the code ended up doing something morally equivalent
to (nreverse '(1 2 . 3)).  Try it and you'll see a similarly confusing
error message.
The reason is that by the time you get to the error, the list has
already been "nreversed" by side-effect, so the arg (which still points
to the cons cell which used to be the first element of the line) now
still points to the same cons-cell, but that cons-cell's cdr has been
set to nil because it was to become the last element of the
returned list.

I've installed a change in trunk which makes the above error include the
problematic non-nil tail, rather than the first element who looks
confusingly normal.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12677; Package emacs. (Fri, 19 Oct 2012 01:50:02 GMT) Full text and rfc822 format available.

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

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Stefan Monnier'" <monnier <at> iro.umontreal.ca>
Cc: 12677-done <at> debbugs.gnu.org
Subject: RE: bug#12677: 24.2.50;
	`nreverse' complains that ("foo") is not `listp'
Date: Thu, 18 Oct 2012 18:47:23 -0700
> My guess is that the code ended up doing something morally equivalent
> to (nreverse '(1 2 . 3)).  Try it and you'll see a similarly confusing
> error message.

I understand your guess, but I think that might not be what was happening.  In
the debugger I evaluated the variable and saw that its full value was just that
singleton list.

But I'm OK with your closing this, as I cannot repro it from emacs -Q and it
does not interfere with my code.

> The reason is that by the time you get to the error, the list has
> already been "nreversed" by side-effect, so the arg (which 
> still points to the cons cell which used to be the first element
> of the line) now still points to the same cons-cell, but that
> cons-cell's cdr has been set to nil because it was to become the
> last element of the returned list.

Do I understand correctly that a true list with a single element should not
present such a problem?

> I've installed a change in trunk which makes the above error 
> include the problematic non-nil tail, rather than the first
> element who looks confusingly normal.

Sounds good.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12677; Package emacs. (Fri, 19 Oct 2012 14:22:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: "Drew Adams" <drew.adams <at> oracle.com>
Cc: 12677-done <at> debbugs.gnu.org
Subject: Re: bug#12677: 24.2.50;
	`nreverse' complains that ("foo") is not `listp'
Date: Fri, 19 Oct 2012 10:19:47 -0400
>> My guess is that the code ended up doing something morally equivalent
>> to (nreverse '(1 2 . 3)).  Try it and you'll see a similarly confusing
>> error message.

> I understand your guess, but I think that might not be what was
> happening.  In the debugger I evaluated the variable and saw that its
> full value was just that singleton list.

Of course that's what you'd see because that's indeed the value *at that
point*, even though it had a different value before nreverse started
modifying the list.  By the time you get the error, the problem data
is gone.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12677; Package emacs. (Fri, 19 Oct 2012 14:27:01 GMT) Full text and rfc822 format available.

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

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Stefan Monnier'" <monnier <at> iro.umontreal.ca>
Cc: 12677-done <at> debbugs.gnu.org
Subject: RE: bug#12677: 24.2.50;
	`nreverse' complains that ("foo") is not `listp'
Date: Fri, 19 Oct 2012 07:24:06 -0700
> Of course that's what you'd see because that's indeed the 
> value *at that point*, even though it had a different value
> before nreverse started modifying the list.  By the time
> you get the error, the problem data is gone.

Got it.  Thx.





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 17 Nov 2012 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 271 days ago.

Previous Next


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