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

From: Stefan Monnier <[email-masked]>
Date: Sat, 25 Dec 2010 15:35:31 -0500

>> 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 selected_window is nil because of Fset_window_configuration, then it
is presumably nil for all the intervening and some of the subsequent
code, and I suspect fixing it earlier in the call chain will be
preferable: e.g., it doesn't make sense to "display_and_set_cursor" in
the "selected_window = nil" case.

        Stefan