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

From: Gregor Zattler <[email-masked]>
Date: Thu, 06 Feb 2025 16:48:56 +0100

Hi Eli,
* Eli Zaretskii <[email-masked]> [2025-02-06; 17:43 +02]:
>> 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

+frame 3
#3  0x00005555555a4370 in XBUFFER (a=...) at ./src/xdisp.c:17024
17024	    XFRAME (frame)->already_hscrolled_p = false;
+print a
$1 = <optimized out>
+xtype
++xgettype $
+++if (CHECK_LISP_OBJECT_TYPE)
++++set $bugfix = $.i
+++set $type = (enum Lisp_Type) (USE_LSB_TAG ? (EMACS_INT) $bugfix & (1 << GCTYPEBITS) - 1 : (EMACS_UINT) $bugfix >> VALBITS)
value has been optimized out

I'll try to use an un-optimized build
but I'm afraid it's too slow for
everyday usage.

HTH, Gregor