Subject: Re: bug#76091: 31.0.50; festure/igc: buffer.h:829: Emacs fatal error: assertion failed: BUFFERP (a)

From: Eli Zaretskii <[email-masked]>
Date: Thu, 06 Feb 2025 17:43:20 +0200

> Date: Thu, 06 Feb 2025 13:49:30 +0100
> From:  Gregor Zattler via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> Dear Emacs developers, I don't know if
> this failed assertion is due to using
> MPS as GC.
> 
> I played along with pdf-tools and
> org-noter when it happened.
> 
> This time I built with a current
> checkout of feature/igc.
> 
> GDB output even further below.
> 
> The crashed session is still in GDB.
> [...]
> Breakpoint 1, terminate_due_to_signal (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=2147483647) at ./src/emacs.c:425
> 425	{
> +bt
> #0  terminate_due_to_signal (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=2147483647) at ./src/emacs.c:425
> #1  0x00005555555b8f5b in die (msg=msg@entry=0x5555559b40d0 "BUFFERP (a)", file=file@entry=0x5555559b40c7 "buffer.h", line=line@entry=829) at ./src/alloc.c:7683
> #2  0x00005555555a0bda in XBUFFER (a=Python Exception <class 'gdb.error'>: value has been optimized out
> ) at ./src/buffer.h:829
> #3  0x00005555555a4370 in XBUFFER (a=Python Exception <class 'gdb.error'>: value has been optimized out
> ) at ./src/xdisp.c:17024
> #4  prepare_menu_bars () at ./src/xdisp.c:14041

This is here:

      FOR_EACH_FRAME (tail, frame)
	{
	  struct frame *f = XFRAME (frame);
	  struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f));
	  if (some_windows
	      && !f->redisplay
	      && !w->redisplay
	      && !XBUFFER (w->contents)->text->redisplay)
	    continue;

And I don't understand how w->contents of a frame's selected window
could fail the BUFFERP test.  Can you tell what the below commands
produce?

  (gdb) frame 3
  (gdb) print a
  (gdb) xtype

Other than that, with all the locals "optimized out", there really is
not much else to do, except analyze the machine instructions and the
corresponding registers.