Subject: Re: bug#18136: 24.4.50; crash in redisplay when calling load-theme

From: Eli Zaretskii <[email-masked]>
Date: Tue, 29 Jul 2014 12:05:11 +0300

> From: Mark Oteiza <[email-masked]>
> Date: Mon, 28 Jul 2014 20:36:06 -0400
> 
> 
> gdb emacs
> run -nw -Q
> 
> M-x load-theme RET some-default-theme RET
> 
> (gdb) xbacktrace al (C function)" (0xbbeea0)
> "redisplay_internal (C function)" (0xbbeea0)
> (gdb) bt
> #0  terminate_due_to_signal (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=40) at emacs.c:359
> #1  0x00000000004fe2e3 in emacs_abort () at sysdep.c:2198
> #2  0x00000000004a81c1 in cmcheckmagic (tty=0x13d82a0) at cm.c:120
> #3  0x0000000000418225 in update_frame_line (f=f@entry=0xc0ab08, vpos=50) at dispnew.c:4839

Martin, this is because of this change in the call to
change_frame_size by init_display:

  @@ -6171,7 +6069,8 @@ init_display (void)
       t->display_info.tty->top_frame = selected_frame;
       change_frame_size (XFRAME (selected_frame),
			  FrameCols (t->display_info.tty),
  -                       FrameRows (t->display_info.tty), 0, 0, 1, 0);
  +                       FrameRows (t->display_info.tty)
  +                      - FRAME_MENU_BAR_LINES (f), 0, 0, 1, 0);

change_frame_size_1 then calls adjust_frame_size with the value one
less than the terminal height, and adjust_frame_size plugs that value
into FrameRows:

      if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f))
	FrameRows (FRAME_TTY (f)) = new_lines;

This lies to Emacs about the terminal height, and cmcheckmagic catches
that.

I don't understand why you subtract FRAME_MENU_BAR_LINES, that sounds
wrong at least for TTY frames.  (We could add that back inside
adjust_frame_size, but it's IMO a bad idea to spread this non-trivial
logic between 2 functions.)