GNU bug report logs - #17123
24.3.50; C-x C-c -> Invalid function: with-current-buffer-window

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Thu, 27 Mar 2014 17:44:02 UTC

Severity: normal

Tags: notabug

Found in version 24.3.50

Done: Glenn Morris <rgm <at> gnu.org>

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 17123 in the body.
You can then email your comments to 17123 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#17123; Package emacs. (Thu, 27 Mar 2014 17:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 27 Mar 2014 17:44:03 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50; C-x C-c -> Invalid function: with-current-buffer-window
Date: Thu, 27 Mar 2014 18:42:19 +0100
Hello,

this kind of issue has been seen and was discussed (without a solution)
already some time ago.  Now I see an incarnation of it using the
emacs-24 branch.

I did the following (using my setup, but that probably doesn't matter):
I had a living process started from Emacs, and I hit C-x C-c.  I get his
error:

Debugger entered--Lisp error: (invalid-function with-current-buffer-window)
  with-current-buffer-window(#<buffer *Process List*> nil [lotsa byte code] nil)
  save-buffers-kill-emacs(nil)
  save-buffers-kill-terminal(nil)
  call-interactively(save-buffers-kill-terminal nil nil)
  command-execute(save-buffers-kill-terminal)

(I have removed the actual byte code).

`with-current-buffer-window' is a macro - which was defined in this
moment, of course.  When I load the source file of
save-buffers-kill-emacs, files.el, the problem is immediately fixed.
When I load the compiled files.elc again, it is there again.

What other users already had experienced was something similar: they got
an error like

    Invalid function: some-macro

where `some-macro' was a defined and well working macro.

I have an idea of what causes this: when you compile some file using a
certain macro that is not (yet) defined, and you load the resulting byte
code, and define the macro just after that, you get the same error
message.  For example, load the byte compiled code of this test file:

--8<---------------cut here---------------start------------->8---
(defun test (x)
  (unknown-macro (+ x 1)))

'(defmacro unknown-macro (&rest body) `(progn ,@body))
--8<---------------cut here---------------end--------------->8---

Now evaluate the defmacro form, and try M-: (test 1).  You get

    test: Invalid function: unknown-macro

If you eval the defun (uncompiled), the error doesn't happen.

(disassemble 'save-buffers-kill-emacs) looks here like this:

...
65	constant  with-current-buffer-window
66	constant  get-buffer-create
67	constant  "*Process List*"
68	call	  1
...

so `with-current-buffer-window' at least was not expanded while byte
compiling the source file while building.

So I think there are two problems here:

1.  While building, the compilation of file.el has to cope with an
undefined macro, which is not good (i.e., a dependency problem).

2.  Compiled code using not yet defined macros doesn't behave "as
expected".


Thanks,

Michael




In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.7)
 of 2014-03-25 on drachen
Windowing system distributor `The X.Org Foundation', version 11.0.11500000
System Description:	Debian GNU/Linux testing (jessie)

Important settings:
  value of $LC_ALL: de_DE.utf8
  value of $LC_COLLATE: C
  value of $LC_TIME: C
  value of $LANG: de_DE.utf8
  locale-coding-system: utf-8-unix





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17123; Package emacs. (Thu, 27 Mar 2014 21:23:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 17123 <at> debbugs.gnu.org
Subject: Re: bug#17123: 24.3.50;
 C-x C-c -> Invalid function: with-current-buffer-window
Date: Thu, 27 Mar 2014 17:22:18 -0400
> --8<---------------cut here---------------start------------->8---
> (defun test (x)
>   (unknown-macro (+ x 1)))

> (defmacro unknown-macro (&rest body) `(progn ,@body))
> --8<---------------cut here---------------end--------------->8---

Right, such code is incorrect and we do not intend to support it.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17123; Package emacs. (Thu, 27 Mar 2014 21:36:01 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 17123 <at> debbugs.gnu.org
Subject: Re: bug#17123: 24.3.50;
 C-x C-c -> Invalid function: with-current-buffer-window
Date: Thu, 27 Mar 2014 17:35:20 -0400
Michael Heerdegen wrote:

> (disassemble 'save-buffers-kill-emacs) looks here like this:
>
> ...
> 65	constant  with-current-buffer-window
> 66	constant  get-buffer-create
> 67	constant  "*Process List*"
> 68	call	  1
> ...
>
> so `with-current-buffer-window' at least was not expanded while byte
> compiling the source file while building.

Then perhaps your build is broken. I have no idea how such a thing is
possible, since loadup.el loads "window" before it loads "files".

> 1.  While building, the compilation of file.el has to cope with an
> undefined macro, which is not good (i.e., a dependency problem).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17123; Package emacs. (Thu, 27 Mar 2014 22:50:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 17123 <at> debbugs.gnu.org
Subject: Re: bug#17123: 24.3.50;
 C-x C-c -> Invalid function: with-current-buffer-window
Date: Thu, 27 Mar 2014 18:47:23 -0400
> Then perhaps your build is broken. I have no idea how such a thing is
> possible, since loadup.el loads "window" before it loads "files".

You'll get that if you compile files.el with an Emacs that dates back to
before that macro was added to window.el.

E.g.

   bzr update -r <older>
   make
   bzr update
   rm lisp/files.elc
   make

could get you there.  "make bootstrap" should fix it for you, tho.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17123; Package emacs. (Thu, 27 Mar 2014 23:00:03 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 17123 <at> debbugs.gnu.org
Subject: Re: bug#17123: 24.3.50;
 C-x C-c -> Invalid function: with-current-buffer-window
Date: Thu, 27 Mar 2014 23:59:19 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> > --8<---------------cut here---------------start------------->8---
> > (defun test (x)
> >   (unknown-macro (+ x 1)))
>
> > (defmacro unknown-macro (&rest body) `(progn ,@body))
> > --8<---------------cut here---------------end--------------->8---
>
> Right, such code is incorrect and we do not intend to support it.

Ok, that makes sense.  And the "invalid function" error is a good pointer to
dependency problems anyway.

Michael.




Added tag(s) notabug; removed tag(s) moreinfo. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 27 Mar 2014 23:08:01 GMT) Full text and rfc822 format available.

Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Thu, 27 Mar 2014 23:08:02 GMT) Full text and rfc822 format available.

Notification sent to Michael Heerdegen <michael_heerdegen <at> web.de>:
bug acknowledged by developer. (Thu, 27 Mar 2014 23:08:03 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: 17123-done <at> debbugs.gnu.org
Subject: Re: bug#17123: 24.3.50;
 C-x C-c -> Invalid function: with-current-buffer-window
Date: Thu, 27 Mar 2014 19:07:09 -0400
So, no bug here then.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17123; Package emacs. (Thu, 27 Mar 2014 23:11:02 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Glenn Morris <rgm <at> gnu.org>, 17123 <at> debbugs.gnu.org
Subject: Re: bug#17123: 24.3.50;
 C-x C-c -> Invalid function: with-current-buffer-window
Date: Fri, 28 Mar 2014 00:10:11 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> You'll get that if you compile files.el with an Emacs that dates back to
> before that macro was added to window.el.
>
> E.g.
>
>    bzr update -r <older>
>    make
>    bzr update
>    rm lisp/files.elc
>    make
>
> could get you there.  "make bootstrap" should fix it for you, tho.

You are perfectly right!  To test the emacs-24 branch, I had removed all
untracked files, but didn't "make bootstrap".  And of course after
rebuilding orderly, the error was gone.  So, sorry for the noise, and
thanks for clarifying!  Please close.


Many thanks,

Michael.




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

This bug report was last modified 11 years and 61 days ago.

Previous Next


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