Subject: bug#15575: 24.3.50; New tty menus crash Emacs

From: Eli Zaretskii <[email-masked]>
Date: Thu, 10 Oct 2013 22:36:54 +0300

> From: Jan Djärv <[email-masked]>
> Date: Thu, 10 Oct 2013 19:35:30 +0200
> Cc: [email-masked]
> 
> >  /* Count how many glyphs to copy and copy the glyphs.  */
> >  for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area)
> >    for (i = 0; i < from->used[area]; i++)
> >      to->glyphs[area][i] = from->glyphs[area][i];  <<<<<<<<<<<<<<
> > 
> 
> It is the same place in the code, but not the same line in the file.
> 
> > then please tell what is the value of 'area' and of 'i' at the point
> > of the crash.
> > 
> 
> On Fedora 19:
> 
> (gdb) p area
> $1 = 1
> (gdb) p i
> $2 = 0
> (gdb) 
> 
> > Btw, did you compile with --enable-checking, i.e. were the 3 eassert
> > statements at the beginning of deep_copy_glyph_row compiled into the
> > program?
> 
> No, I did not.  I usually don't because the checkings more often than not trip on something that really isn't a bug.  I've never caught a real error with it.
> 
> This one triggers:
> 
> #3  0x0000000000449d2b in deep_copy_glyph_row (from=<optimized out>, 
>     to=0xce9e40) at /home/jhd/src/emacs/current/src/xdisp.c:20597
> 20597	  eassert (to->used[0] == from->used[0]);
> 
> (gdb) p to->used[0]
> $1 = -15072
> 
> There is some memory corruption.  If I press F11 twice and then F10, the crash does not happen. The menu appears but there are major redrawing problems, for example, going down in the menu does not work, it just scrolls the buffer instead until the menu disappears over the top, the buffer is not redrawn correctly when the menu goes away, nor is the menu bar.  I did not test it much.
> Could be another symptom of the memory corruption.

Can you please try the latest trunk (after reverting the patch you
applied on my request)?  I made some changes that perhaps could fix
this.

(I don't understand why the code worked for others on Fedora; are you
using a different development environment: compiler and/or library or
something?)