Subject: bug#670: bug#1077: 23.0.60; x-create-frame: (wrong-type-argument number-or-marker-p nil)

From: "Drew Adams" <[email-masked]>
Date: Fri, 26 Nov 2010 18:52:09 -0800

I am still seeing this systematically, including in the latest dev version,

In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2010-11-22 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4) --no-opt --cflags
-Ic:/imagesupport/include'

Below is a backtrace from this current version.

One scenario that provokes the error:

I have a standalone minibuffer frame. I bind a key in `completion-list-mode-map'
during minibuffer completion to call `describe-function' on a command name
candidate in *Completions* that is clicked with mouse-2.  *Help*, like
*Completions* is a special-display buffer that appears in its own frame. Input
from *Completions* is redirected to the minibuffer.

I do C-h f and get some candidates in *Completions*. I click one with mouse-2.
*Help* shows its doc. I click the file-name link in *Help* to see the source
library for the function. That's when I get the error.

Same thing if I use a key bound in `minibuffer-must-match-map' and type a
candidate then hit that key. Either way I see the function doc in *Help*, and
when I click the file-name link I get the error.

There are other ways to reproduce it.  They all involve an action during
minibuffer completion.

Another clue, perhaps: I get this error when I do something in the minibuffer
(invoke some function) that tries to create a frame.  For example, if the *Help*
frame doesn't already exist when I hit the key mentioned above to show the
output from `describe-function' (for some completion candidate) in *Help*, then
I get the error when it tries to create the *Help* frame.

I tried to follow `display-buffer' in the debugger.  I can't get further than
the C-code call to x-create-frame.  If you look at the date when I originally
filed this bug you should be able to see when some change was made to the
x-create-frame C-code that introduced this regression.  At least you should be
able to see some code in x-create-frame or called from it that tries to test (>
SOMETHING1 SOMETHING2), which ends up calling (> nil 0), raising the error.  I
tried ediffing the Emacs 22.1 C code for x-create-frame against the current C
code for it, but I couldn't guess anything (that single function definition
alone is over 12,000 chars!).

It's been this way since Emacs 23 (even pretests for 23).  No one has tried to
look into this.

-----------------------

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  >(nil 0)
  x-create-frame(((visibility) (tool-bar-lines . 0) (fringe . 0) (right-fringe .
0) (left-fringe . 0) (icon-type) (vertical-scroll-bars . right) (user-position .
t) (minibuffer) (height . 35) (width . 80) (left . 0) (top . 0) (menu-bar-lines
. 1) (cursor-type . bar)))
  x-create-frame-with-faces(((tool-bar-lines . 0) (fringe . 0) (right-fringe .
0) (left-fringe . 0) (icon-type) (vertical-scroll-bars . right) (user-position .
t) (minibuffer) (height . 35) (width . 80) (left . 0) (top . 0) (menu-bar-lines
. 1) (cursor-type . bar) (cursor-color . "Red") (mouse-color . "Red") (font .
"-*-Lucida Console-normal-r-*-*-14-112-96-96-c-*-iso8859-1") (background-color .
"LightBlue") (foreground-color . "Black")))
  make-frame(nil)
  (lambda nil (make-frame pop-up-frame-alist))()
  funcall((lambda nil (make-frame pop-up-frame-alist)))
  (frame-selected-window (funcall pop-up-frame-function))
  (let ((win (frame-selected-window (funcall pop-up-frame-function))))
(window--display-buffer-2 buffer win display-buffer-mark-dedicated))
  (cond ((not (buffer-live-p buffer)) (error "No such buffer %s" buffer))
(display-buffer-function (funcall display-buffer-function buffer
not-this-window)) ((and (not not-this-window) (eq (window-buffer
(selected-window)) buffer)) (window--display-buffer-1 (selected-window))) ((and
can-use-selected-window (same-window-p name-of-buffer))
(window--display-buffer-2 buffer (selected-window))) ((let ((frames (or frame
(and (or use-pop-up-frames display-buffer-reuse-frames ...) 0)
(last-nonminibuffer-frame)))) (setq window-to-use (catch (quote found) (dolist
(window (get-buffer-window-list buffer ... frames)) (when (or
can-use-selected-window ...) (throw ... window)))))) (window--display-buffer-1
window-to-use)) ((and special-display-function (let ((pars (special-display-p
name-of-buffer))) (when pars (funcall special-display-function buffer (if (listp
pars) pars)))))) ((or use-pop-up-frames (not frame-to-use)) (let ((win
(frame-selected-window (funcall pop-up-frame-function))))
(window--display-buffer-2 buffer win display-buffer-mark-dedicated))) ((and
pop-up-windows (or (not (frame-parameter frame-to-use (quote unsplittable)))
(and (eq frame-to-use (selected-frame)) (setq frame-to-use
(last-nonminibuffer-frame)) (window--frame-usable-p frame-to-use) (not
(frame-parameter frame-to-use (quote unsplittable))))) (setq window-to-use (or
(window--try-to-split-window (get-largest-window frame-to-use t))
(window--try-to-split-window (get-lru-window frame-to-use t)))))
(window--display-buffer-2 buffer window-to-use display-buffer-mark-dedicated))
((let ((window-to-undedicate (and not-this-window (not (window-dedicated-p))
(set-window-dedicated-p (selected-window) t) (selected-window))))
(unwind-protect (setq window-to-use (or (get-lru-window frame-to-use) (let (...)
(unless ... window)) (get-largest-window (quote visible)) (let (...) (unless ...
window)) (get-largest-window 0) (frame-selected-window (funcall
pop-up-frame-function)))) (when (window-live-p window-to-undedicate)
(set-window-dedicated-p window-to-undedicate nil))))
(window--even-window-heights window-to-use) (window--display-buffer-2 buffer
window-to-use)))
  (let* ((can-use-selected-window (not (or not-this-window (window-dedicated-p
(selected-window)) (window-minibuffer-p)))) (buffer (if (bufferp buffer-or-name)
buffer-or-name (get-buffer buffer-or-name))) (name-of-buffer (buffer-name
buffer)) (use-pop-up-frames (if (eq pop-up-frames (quote graphic-only))
(display-graphic-p) pop-up-frames)) (frame-to-use (or (window--frame-usable-p
(selected-frame)) (window--frame-usable-p (last-nonminibuffer-frame))))
window-to-use) (cond ((not (buffer-live-p buffer)) (error "No such buffer %s"
buffer)) (display-buffer-function (funcall display-buffer-function buffer
not-this-window)) ((and (not not-this-window) (eq (window-buffer
(selected-window)) buffer)) (window--display-buffer-1 (selected-window))) ((and
can-use-selected-window (same-window-p name-of-buffer))
(window--display-buffer-2 buffer (selected-window))) ((let ((frames (or frame
(and ... 0) (last-nonminibuffer-frame)))) (setq window-to-use (catch (quote
found) (dolist (window ...) (when ... ...))))) (window--display-buffer-1
window-to-use)) ((and special-display-function (let ((pars (special-display-p
name-of-buffer))) (when pars (funcall special-display-function buffer (if ...
pars)))))) ((or use-pop-up-frames (not frame-to-use)) (let ((win
(frame-selected-window (funcall pop-up-frame-function))))
(window--display-buffer-2 buffer win display-buffer-mark-dedicated))) ((and
pop-up-windows (or (not (frame-parameter frame-to-use (quote unsplittable)))
(and (eq frame-to-use (selected-frame)) (setq frame-to-use
(last-nonminibuffer-frame)) (window--frame-usable-p frame-to-use) (not
(frame-parameter frame-to-use ...)))) (setq window-to-use (or
(window--try-to-split-window (get-largest-window frame-to-use t))
(window--try-to-split-window (get-lru-window frame-to-use t)))))
(window--display-buffer-2 buffer window-to-use display-buffer-mark-dedicated))
((let ((window-to-undedicate (and not-this-window (not ...)
(set-window-dedicated-p ... t) (selected-window)))) (unwind-protect (setq
window-to-use (or (get-lru-window frame-to-use) (let ... ...)
(get-largest-window ...) (let ... ...) (get-largest-window 0)
(frame-selected-window ...))) (when (window-live-p window-to-undedicate)
(set-window-dedicated-p window-to-undedicate nil))))
(window--even-window-heights window-to-use) (window--display-buffer-2 buffer
window-to-use))))
  display-buffer(#<buffer delim-col.el> nil)
  pop-to-buffer(#<buffer delim-col.el>)