GNU bug report logs - #55684
29.0.50; wrong-type-argument in minibuffer-only frames

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Fri, 27 May 2022 20:10:01 UTC

Severity: normal

Merged with 55687

Found in version 29.0.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 55684 in the body.
You can then email your comments to 55684 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 acm <at> muc.de, bug-gnu-emacs <at> gnu.org:
bug#55684; Package emacs. (Fri, 27 May 2022 20:10:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
New bug report received and forwarded. Copy sent to acm <at> muc.de, bug-gnu-emacs <at> gnu.org. (Fri, 27 May 2022 20:10:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; wrong-type-argument in minibuffer-only frames
Date: Fri, 27 May 2022 16:09:13 -0400
Package: Emacs
Version: 29.0.50


    src/emacs -Q --eval '(setq default-frame-alist `((minibuffer . nil)))'

Stays "frozen" because of a wrong-type-argument error in
`Fset_frame_selected_window` on `CHECK_LIVE_WINDOW (window);`.

The patch below seems to "fix" it, but I must admit that I don't really
understand this code (see for example the FIXME comment in the patch).
Does someone know what is the user-level behavior we're trying to
obtain here?

It seems that this comes from Alan's commit dfa3e6f424b20fe27d904.


        Stefan


diff --git a/src/frame.c b/src/frame.c
index 252dc591bfa..dc55004b193 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1576,8 +1576,14 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor
      to a different window, the most recently used one, unless there is a
      valid active minibuffer in the mini-window.  */
   if (EQ (f->selected_window, f->minibuffer_window)
+         /* FIXME: Can this test ever fail?  I.e. can 'minibuffer_window'
+            ever contain a non-mini-buffer (and if so, should we care here)? */
       && NILP (Fminibufferp (XWINDOW (f->minibuffer_window)->contents, Qt)))
-    Fset_frame_selected_window (frame, call1 (Qget_mru_window, frame), Qnil);
+    {
+      Lisp_Object w = call1 (Qget_mru_window, frame);
+      if (!NILP (w))            /* Can be nil in minibuffer-only frames.  */
+        Fset_frame_selected_window (frame, w, Qnil);
+    }
 
   Fselect_window (f->selected_window, norecord);
 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55684; Package emacs. (Sat, 28 May 2022 05:57:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>,
 martin rudalics <rudalics <at> gmx.at>
Cc: acm <at> muc.de, 55684 <at> debbugs.gnu.org
Subject: Re: bug#55684: 29.0.50; wrong-type-argument in minibuffer-only frames
Date: Sat, 28 May 2022 08:56:04 +0300
> Cc: Alan Mackenzie <acm <at> muc.de>
> Date: Fri, 27 May 2022 16:09:13 -0400
> From:  Stefan Monnier via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> Package: Emacs
> Version: 29.0.50

Doesn't the same problem exist on the emacs-28 branch?  I can
reproduce it there.

> -    Fset_frame_selected_window (frame, call1 (Qget_mru_window, frame), Qnil);
> +    {
> +      Lisp_Object w = call1 (Qget_mru_window, frame);
> +      if (!NILP (w))            /* Can be nil in minibuffer-only frames.  */
> +        Fset_frame_selected_window (frame, w, Qnil);

The NILP(w) test should probably be WINDOW_LIVE_P(w).  Martin, do you
agree?




Merged 55684 55687. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 28 May 2022 06:30:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55684; Package emacs. (Sat, 28 May 2022 10:49:02 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: acm <at> muc.de, 55684 <at> debbugs.gnu.org
Subject: Re: bug#55684: 29.0.50; wrong-type-argument in minibuffer-only frames
Date: Sat, 28 May 2022 10:48:32 +0000
Hello, Stefan.

On Fri, May 27, 2022 at 16:09:13 -0400, Stefan Monnier wrote:
> Package: Emacs
> Version: 29.0.50


>     src/emacs -Q --eval '(setq default-frame-alist `((minibuffer . nil)))'

> Stays "frozen" because of a wrong-type-argument error in
> `Fset_frame_selected_window` on `CHECK_LIVE_WINDOW (window);`.

Yes.  This is unfortunate.  Sorry.

> The patch below seems to "fix" it, but I must admit that I don't really
> understand this code (see for example the FIXME comment in the patch).
> Does someone know what is the user-level behavior we're trying to
> obtain here?

When the mini-window in frame F1 is the selected window, and we switch
to a different frame F2, F1 remembers the mini-window as its selected
window.  When we later switch back to F1, we check whether there is
still a minibuffer in the mini-window, and if not select a different
window.

There are several reasons why there might not be a minibuffer on
returning to F1.  The MB in F1 might have moved to F2 on the frame
switch, and been terminated there, for example.

> It seems that this comes from Alan's commit dfa3e6f424b20fe27d904.


>         Stefan


> diff --git a/src/frame.c b/src/frame.c
> index 252dc591bfa..dc55004b193 100644
> --- a/src/frame.c
> +++ b/src/frame.c
> @@ -1576,8 +1576,14 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor
>       to a different window, the most recently used one, unless there is a
>       valid active minibuffer in the mini-window.  */
>    if (EQ (f->selected_window, f->minibuffer_window)
> +         /* FIXME: Can this test ever fail?  I.e. can 'minibuffer_window'
> +            ever contain a non-mini-buffer (and if so, should we care here)? */

Yes, the test can fail.  The buffer in the mini-window might be (the
non-active) minibuffer 0.  The meaning of the argument Qt is to return
non-nil only for active minibuffers.

>        && NILP (Fminibufferp (XWINDOW (f->minibuffer_window)->contents, Qt)))
> -    Fset_frame_selected_window (frame, call1 (Qget_mru_window, frame), Qnil);
> +    {
> +      Lisp_Object w = call1 (Qget_mru_window, frame);
> +      if (!NILP (w))            /* Can be nil in minibuffer-only frames.  */
> +        Fset_frame_selected_window (frame, w, Qnil);
> +    }
 
>    Fselect_window (f->selected_window, norecord);

I think the patch looks OK.  I'm going to comment on Eli's suggestion.

-- 
Alan Mackenzie (Nuremberg, Germany).





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55684; Package emacs. (Sat, 28 May 2022 10:52:01 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: martin rudalics <rudalics <at> gmx.at>, 55684 <at> debbugs.gnu.org,
 Stefan Monnier <monnier <at> iro.umontreal.ca>, acm <at> muc.de
Subject: Re: bug#55684: 29.0.50; wrong-type-argument in minibuffer-only frames
Date: Sat, 28 May 2022 10:51:25 +0000
Hello, Eli.

On Sat, May 28, 2022 at 08:56:04 +0300, Eli Zaretskii wrote:
> > Cc: Alan Mackenzie <acm <at> muc.de>
> > Date: Fri, 27 May 2022 16:09:13 -0400
> > From:  Stefan Monnier via "Bug reports for GNU Emacs,
> >  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>

> > Package: Emacs
> > Version: 29.0.50

> Doesn't the same problem exist on the emacs-28 branch?  I can
> reproduce it there.

> > -    Fset_frame_selected_window (frame, call1 (Qget_mru_window, frame), Qnil);
> > +    {
> > +      Lisp_Object w = call1 (Qget_mru_window, frame);
> > +      if (!NILP (w))            /* Can be nil in minibuffer-only frames.  */
> > +        Fset_frame_selected_window (frame, w, Qnil);

> The NILP(w) test should probably be WINDOW_LIVE_P(w).  Martin, do you
> agree?

I'm not Martin, but I think WINDOW_LIVE is safe, but might not be
needed.  I think get-mru-window will only return a live window or nil.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55684; Package emacs. (Sat, 28 May 2022 10:58:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: rudalics <at> gmx.at, 55684 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca,
 acm <at> muc.de
Subject: Re: bug#55684: 29.0.50; wrong-type-argument in minibuffer-only frames
Date: Sat, 28 May 2022 13:57:25 +0300
> Date: Sat, 28 May 2022 10:51:25 +0000
> Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>,
>   martin rudalics <rudalics <at> gmx.at>, 55684 <at> debbugs.gnu.org, acm <at> muc.de
> From: Alan Mackenzie <acm <at> muc.de>
> 
> Hello, Eli.
> 
> On Sat, May 28, 2022 at 08:56:04 +0300, Eli Zaretskii wrote:
> > > Cc: Alan Mackenzie <acm <at> muc.de>
> > > Date: Fri, 27 May 2022 16:09:13 -0400
> > > From:  Stefan Monnier via "Bug reports for GNU Emacs,
> > >  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> > > Package: Emacs
> > > Version: 29.0.50
> 
> > Doesn't the same problem exist on the emacs-28 branch?  I can
> > reproduce it there.
> 
> > > -    Fset_frame_selected_window (frame, call1 (Qget_mru_window, frame), Qnil);
> > > +    {
> > > +      Lisp_Object w = call1 (Qget_mru_window, frame);
> > > +      if (!NILP (w))            /* Can be nil in minibuffer-only frames.  */
> > > +        Fset_frame_selected_window (frame, w, Qnil);
> 
> > The NILP(w) test should probably be WINDOW_LIVE_P(w).  Martin, do you
> > agree?
> 
> I'm not Martin, but I think WINDOW_LIVE is safe, but might not be
> needed.  I think get-mru-window will only return a live window or nil.

It starts with a list of live windows, that's true, but who will
guarantee that while it's processing some window cannot be deleted?
WINDOW_LIVE_P is not expensive enough to make such assumptions.

In any case, even if we are sure a window returned by get-mru-window
I'd prefer to use WINDOWP instead of NILP here.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55684; Package emacs. (Sat, 28 May 2022 13:10:02 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: rudalics <at> gmx.at, 55684 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca,
 acm <at> muc.de
Subject: Re: bug#55684: 29.0.50; wrong-type-argument in minibuffer-only frames
Date: Sat, 28 May 2022 13:09:17 +0000
Hello, Eli.

On Sat, May 28, 2022 at 13:57:25 +0300, Eli Zaretskii wrote:
> > Date: Sat, 28 May 2022 10:51:25 +0000
> > Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>,
> >   martin rudalics <rudalics <at> gmx.at>, 55684 <at> debbugs.gnu.org, acm <at> muc.de
> > From: Alan Mackenzie <acm <at> muc.de>

> > Hello, Eli.

> > On Sat, May 28, 2022 at 08:56:04 +0300, Eli Zaretskii wrote:
> > > > Cc: Alan Mackenzie <acm <at> muc.de>
> > > > Date: Fri, 27 May 2022 16:09:13 -0400
> > > > From:  Stefan Monnier via "Bug reports for GNU Emacs,
> > > >  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>

> > > > Package: Emacs
> > > > Version: 29.0.50

> > > Doesn't the same problem exist on the emacs-28 branch?  I can
> > > reproduce it there.

> > > > -    Fset_frame_selected_window (frame, call1 (Qget_mru_window, frame), Qnil);
> > > > +    {
> > > > +      Lisp_Object w = call1 (Qget_mru_window, frame);
> > > > +      if (!NILP (w))            /* Can be nil in minibuffer-only frames.  */
> > > > +        Fset_frame_selected_window (frame, w, Qnil);

> > > The NILP(w) test should probably be WINDOW_LIVE_P(w).  Martin, do you
> > > agree?

> > I'm not Martin, but I think WINDOW_LIVE is safe, but might not be
> > needed.  I think get-mru-window will only return a live window or nil.

> It starts with a list of live windows, that's true, but who will
> guarantee that while it's processing some window cannot be deleted?
> WINDOW_LIVE_P is not expensive enough to make such assumptions.

That makes sense.

> In any case, even if we are sure a window returned by get-mru-window
> I'd prefer to use WINDOWP instead of NILP here.

I've committed Stefan's patch, amended with WINDOW_LIVE_P and an extra
comment to the emacs-28 branch.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55684; Package emacs. (Sat, 28 May 2022 13:19:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: rudalics <at> gmx.at, 55684 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#55684: 29.0.50; wrong-type-argument in minibuffer-only frames
Date: Sat, 28 May 2022 16:18:14 +0300
> Date: Sat, 28 May 2022 13:09:17 +0000
> Cc: monnier <at> iro.umontreal.ca, rudalics <at> gmx.at, 55684 <at> debbugs.gnu.org,
>   acm <at> muc.de
> From: Alan Mackenzie <acm <at> muc.de>
> 
> > It starts with a list of live windows, that's true, but who will
> > guarantee that while it's processing some window cannot be deleted?
> > WINDOW_LIVE_P is not expensive enough to make such assumptions.
> 
> That makes sense.
> 
> > In any case, even if we are sure a window returned by get-mru-window
> > I'd prefer to use WINDOWP instead of NILP here.
> 
> I've committed Stefan's patch, amended with WINDOW_LIVE_P and an extra
> comment to the emacs-28 branch.

Thanks.




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Sat, 28 May 2022 14:23:02 GMT) Full text and rfc822 format available.

Notification sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
bug acknowledged by developer. (Sat, 28 May 2022 14:23:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 55684-done <at> debbugs.gnu.org
Subject: Re: bug#55684: 29.0.50; wrong-type-argument in minibuffer-only frames
Date: Sat, 28 May 2022 10:22:24 -0400
>> @@ -1576,8 +1576,14 @@ do_switch_frame (Lisp_Object frame, int track, int for_deletion, Lisp_Object nor
>>       to a different window, the most recently used one, unless there is a
>>       valid active minibuffer in the mini-window.  */
>>    if (EQ (f->selected_window, f->minibuffer_window)
>> +         /* FIXME: Can this test ever fail?  I.e. can 'minibuffer_window'
>> +            ever contain a non-mini-buffer (and if so, should we care here)? */
>>        && NILP (Fminibufferp (XWINDOW (f->minibuffer_window)->contents, Qt)))
>
> Yes, the test can fail.  The buffer in the mini-window might be (the
> non-active) minibuffer 0.  The meaning of the argument Qt is to return
> non-nil only for active minibuffers.

Ah, indeed I missed this detail.  I guess that mini window can
also hold the echo area.  Thanks for the explanation,


        Stefan





Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Sat, 28 May 2022 14:23:02 GMT) Full text and rfc822 format available.

Notification sent to Aaron Jensen <aaronjensen <at> gmail.com>:
bug acknowledged by developer. (Sat, 28 May 2022 14:23:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 27 Jun 2022 11:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 300 days ago.

Previous Next


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