Subject: Re: bug#54183: 28.0.91; Emacs crashes on bookmark-jump

From: Eli Zaretskii <[email-masked]>
Date: Tue, 01 Mar 2022 16:43:58 +0200

> From: Gustavo Barros <[email-masked]>
> Cc: [email-masked]
> Date: Mon, 28 Feb 2022 15:33:27 -0300
> 
> > I hope you didn't kill this session and didn't quit GDB, did you?
> 
> Oops... sorry, Eli, first thing I did.  I did not even consider not 
> doing it.
> 
> What follows is from a different session/crash, but I included the first 
> info anew. I'll try to keep this session alive this time (I've used a 
> named server for this, since it's my main computer and I'd like to keep 
> using Emacs regularly in it in the meantime).

You can kill that session now, thanks.

> 1439	      x_cr_draw_image (f, gc, fringe_bmp[p->which], 0, p->dh,
> (gdb) print p->which
> $1 = 24
> (gdb) print max_fringe_bmp
> $2 = 41
> (gdb) print fringe_bmp[p->which]
> $3 = (cairo_pattern_t *) 0x0
> (gdb) print max_used_fringe_bitmap
> $4 = 30
> (gdb) 

OK.  I think I have an idea what's going on, but more details are
needed to find the culprit and devise the solution.  So I need you to
perform a more complex experiment and report the results.

Below are the GDB commands I'd like you to use this time:

  source /path/to/emacs/src/.gdbinit
  break xterm.c:587
  commands
   bt
   print which
   print max_fringe_bmp
   continue
   end
  break xterm.c:602
  commands
   bt
   print which
   print max_fringe_bmp
   continue
   end
  continue

(Replace "/path/to/emacs/src" with the actual absolute file name of
the directory where you have the Emacs C source files, and where the
.gdbinit file is.  If you don't have the source tree, perhaps install
it.)

The above is a lot to type, so I suggest to prepare a file with all of
those commands, so that you could tell GDB to read all of them in one
swell whoop.

There's a complication here: to have a clear idea what happens with
the fringe bitmaps, we need to activate the above commands _before_
Emacs reads your init files.  To make sure we succeed, we need to
cause Emacs to pause during startup, so that you will have enough time
to attach to it and type the commands we need, before the init files
are read.  So here's what I ask you to do: prepare a file
~/.emacs.d/early-init.el, and make this its first line:

   (sleep-for 100)

(If you already have an early-init.el file, just insert the above line
at its very beginning.)

(The number 100 is in seconds; if it is not enough for what I describe
below, enlarge it and try again.)

Now start Emacs as you do via emacsclient, so that the problem
reproduces.  It will start and shortly pause for 100 sec.  During that
time, attach GDB to the Emacs process, as you did before, and once GDB
gets control, type this command at GDB prompt:

  source /path/to/command/file

where /path/to/command/file is the file name of the file where you
stored the above GDB commands.  Then wait.  Emacs will continue
running, will hit those 2 breakpoints, and will collect the backtraces
from each time it hits the breakpoint.  Now perform the commands you
need to cause it to crash.  Eventually, Emacs will crash.  Then post
everything GDB printed until and including the crash (it could be a
lot, so compressing it is an option) here, and let's hope it will give
us enough info to understand the root cause of the crash.

TIA