Subject: bug#38748: 28.0.50; crash on MacOS 10.15.2

From: Eli Zaretskii <[email-masked]>
Date: Sun, 29 Dec 2019 21:31:17 +0200

> From: Andrii Kolomoiets <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sun, 29 Dec 2019 21:01:42 +0200
> 
> I can print the 'last_marked_index':
> 
> (gdb) p last_marked_index
> $2 = 41
> 
> But what can I do with 'last_marked'?
> 
> (gdb) p last_marked[40]
> 'last_marked' has unknown type; cast it to its declared type

last_marked is an array of Lisp objects, arranged in circular order,
i.e. when the index reaches the last element, it is reset back to
zero.

To print the object at last_marked[i], for some i, you do

  (gdb) p last_marked[i]
  (gdb) xtype

The xtype command will tell you the type of the Lisp object.  You then
display it with the corresponding xTYPE command: xint for an integer,
xcons for a cons cell, xstring for a string, xvector for a vector,
xbuffer for a buffer, etc.  Here's a short example:

  (gdb) p last_marked_index
  $2 = 1
  (gdb) p last_marked[0]
  $3 = XIL(0x8000000006287630)
  (gdb) xtype
  Lisp_String
  (gdb) xstring
  $4 = (struct Lisp_String *) 0x6287630
  " *buffer-defaults*"

So in this example, the last marked object was a Lisp string whose
contents is " *buffer-defaults*".  GDB stores its C definition in
history slot $4, so we can look at its details:

  (gdb) p *$4
  $5 = {
    u = {
      s = {
	size = 18,
	size_byte = -2,
	intervals = 0x0,
	data = 0x19a1dea <DEFAULT_REHASH_SIZE+14054> " *buffer-defaults*"
      },
      next = 0x12,
      gcaligned = 18 '\022'
    }
  }

All of those commands are in src/.gdbinit; if GDB says it doesn't know
these commands, tell it to read that file:

  (gdb) source /path/to/emacs/src/.gdbinit

If last_marked_index is 41, you should print the objects starting from
last_marked[40], going back (39, 38, 37, etc.), trying to find the
object that is corrupted (e.g., the corresponding xTYPE command will
error out trying to display it).