Subject: Re: bug#77988: 31.0.50; No more images after fullscreen and load-theme

From: Elijah Gabe Pérez <[email-masked]>
Date: Wed, 21 May 2025 22:58:38 -0600

Eli Zaretskii <[email-masked]> writes:

>> From: Elijah Gabe Pérez <[email-masked]>
>> Cc: [email-masked],  [email-masked],  [email-masked]
>> Date: Mon, 19 May 2025 14:06:56 -0600

[...]

>
> OK, so the image cache stays put.  But what about its contents?  To
> see this, we first need to know the cache slot where this image is
> stored.  Here's how:
>
> After visiting the image, type C-l and define one additional
> breakpoint:
>
>   (gdb) break set_cursor_from_row
>   (gdb) c
>

[...]

> Do this before and after the corruption, and let's see if the cached
> image changes.  Notes:
>
>   . the breakpoint in set_cursor_from_row gets hit very frequently, so
>     disable it after you use it the first time (the command is
>     "disable N" where N is the number of the breakpoint), then do
>     whatever it takes to have the image display incorrectly, then
>     enable the breakpoint ("enable N") after C-l
>   . the cache slot of the image might change after it gets corrupted,
>     so don't assume it's the same slot number, but instead look at
>     what the "pgrow" command shows, and use that.

Fine,

This is the result before the image corruption:

(gdb) n
18364	  struct glyph *end = glyph + row->used[TEXT_AREA];
(gdb) pgrow
TEXT: 2 glyphs
  0    0: IMAGE[25] slice=0,0,260,264 pos=1 w=260 a+d=132+132 MB
  1  260: CHAR[ ] pos=0 blev=0,btyp=B w=9 a+d=132+132 MB

[...]

(gdb) p $7->image_cache
$8 = (struct image_cache *) 0xc86cc0
(gdb) p *$7->image_cache
$9 = {
  buckets = 0xace870,
  images = 0xbaf1c0,
  size = 50,
  used = 26,
  refcount = 1,
  scaling_col_width = 10
}

(gdb) p *$7->image_cache->images[25]
$10 = {
  timestamp = {
    tv_sec = 1747799910,
    tv_nsec = 355847956
  },
  pixmap = 20972097,
  mask = 0,
  ximg = 0x0,
  mask_img = 0x0,
  picture = 20972098,
  mask_picture = 0,
  original_width = 260,
  original_height = 264,
  colors = 0x0,
  ncolors = 0,
  background = 16777215,
  face_foreground = 0,
  face_background = 16777215,
  face_font_size = 15,
  face_font_family = 0x10e7e10 "Adwaita Mono",
  face_font_height = 20,
  face_font_width = 9,
  background_transparent = false,
  background_valid = true,
  background_transparent_valid = false,
  width = 260,
  height = 264,
  scale = 1,
  corners = {0, 0, -1, 0},
  ascent = 50,
  spec = {
    i = 0x7ffff180f743
  },
  dependencies = {
    i = 0x7ffff180e253
  },
  relief = 0,
  hmargin = 0,
  vmargin = 0,
  type = 0x849a80 <image_types+32>,
  load_failed_p = false,
  lisp_data = {
    i = 0x0
  },
  hash = 2639822920428639045,
  id = 25,
  next = 0x0,
  prev = 0x0
}

* (After the svg was displayed incorrectly):

(gdb) n
18364	  struct glyph *end = glyph + row->used[TEXT_AREA];
(gdb) pgrow
TEXT: 2 glyphs
  0    0: IMAGE[26] slice=0,0,260,264 pos=1 w=260 a+d=132+132 MB
  1  260: CHAR[ ] pos=0 blev=0,btyp=B w=9 a+d=132+132 MB

[...]

(gdb) p $17->image_cache
$18 = (struct image_cache *) 0xc86cc0
(gdb) p *$17->image_cache
$19 = {
  buckets = 0xace870,
  images = 0xbaf1c0,
  size = 50,
  used = 27,
  refcount = 1,
  scaling_col_width = 10
}
(gdb) p *$17->image_cache->images[25]
$20 = {
  timestamp = {
    tv_sec = 1747800104,
    tv_nsec = 6461903
  },
  pixmap = 20972097,
  mask = 0,
  ximg = 0x0,
  mask_img = 0x0,
  picture = 20972098,
  mask_picture = 0,
  original_width = 260,
  original_height = 264,
  colors = 0x0,
  ncolors = 0,
  background = 16777215,
  face_foreground = 0,
  face_background = 16777215,
  face_font_size = 15,
  face_font_family = 0x10e7e10 "Adwaita Mono",
  face_font_height = 20,
  face_font_width = 9,
  background_transparent = false,
  background_valid = true,
  background_transparent_valid = false,
  width = 260,
  height = 264,
  scale = 1,
  corners = {0, 0, -1, 0},
  ascent = 50,
  spec = {
    i = 0x7ffff180f743
  },
  dependencies = {
    i = 0x7ffff180e253
  },
  relief = 0,
  hmargin = 0,
  vmargin = 0,
  type = 0x849a80 <image_types+32>,
  load_failed_p = false,
  lisp_data = {
    i = 0x0
  },
  hash = 2639822920428639045,
  id = 25,
  next = 0x0,
  prev = 0x0
}

It doesn't seem to make much difference, I've tested reverting commit
6ea69fc and it seems it fixes this (as Alan said).

Also It seems this bug has been around since emacs 29.1.
-- 
                                          - E.G via GNU Emacs and Org.