Subject: bug#7728: 24.0.50; GDB backtrace from abort

From: Eli Zaretskii <[email-masked]>
Date: Sat, 25 Dec 2010 11:38:05 +0200

> From: "Drew Adams" <[email-masked]>
> Date: Fri, 24 Dec 2010 08:55:20 -0800
> Cc: 
> 
> Program received signal SIGTRAP, Trace/breakpoint trap.
> [Switching to Thread 3684.0x1210]
> 0x7c90120f in ntdll!DbgUiConnectToDbg () from C:\WINDOWS\system32\ntdll.dll
> (gdb) bt
> #0  0x7c90120f in ntdll!DbgUiConnectToDbg () from C:\WINDOWS\system32\ntdll.dll
> #1  0x01309b9f in w32_abort () at w32fns.c:7312
> #2  0x0104a0af in die (msg=0x159401c "assertion failed:
> WINDOWP(selected_window)",
>     file=0x1593ee0 "xdisp.c", line=1156) at alloc.c:6129
> #3  0x0116327a in window_text_bottom_y (w=0x58b2c00) at xdisp.c:1156

The abort happens in this source line in window_text_bottom_y:

    height -= CURRENT_MODE_LINE_HEIGHT (w);

The macro CURRENT_MODE_LINE_HEIGHT accesses selected_window:

  #define CURRENT_MODE_LINE_HEIGHT(W)				\
       (current_mode_line_height >= 0				\
	? current_mode_line_height				\
	: (MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix)	\
	   ? MATRIX_MODE_LINE_HEIGHT ((W)->current_matrix)	\
	   : estimate_mode_line_height (XFRAME ((W)->frame),	\
					CURRENT_MODE_LINE_FACE_ID (W))))

  #define CURRENT_MODE_LINE_FACE_ID(W)		\
	  (CURRENT_MODE_LINE_FACE_ID_3((W), XWINDOW (selected_window), (W)))

and XWINDOW tries to assert (under ENABLE_CHECKING) that its argument
is indeed a window.

So it looks like somehow we get into selected_window a value that is
not a window.  I'm guessing it was nil in this case.

If having selected_window that is not a window is legitimate, then one
possible solution would be to extend CURRENT_MODE_LINE_FACE_ID to
handle that case gracefully.  After all, all it does is choose between
MODE_LINE_FACE_ID and MODE_LINE_INACTIVE_FACE_ID.