On Thu, Jan 31, 2019 at 3:26 PM Eli Zaretskii <eliz@gnu.org> wrote:

OK, so here's a way that could potentially find the culprit:

  $ cd /path/to/emacs/src
  $ gdb ./emacs
  ...
  (gdb) source ./.gdbinit
  (gdb) break fill_image_glyph_string
  (gdb) run

(gdb) break fill_image_glyph_string
Breakpoint 3 at 0x4377e1: file xdisp.c, line 26151.
(gdb) run
Starting program: /home/kmodi/downloads/git/emacs/src/emacs
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffec3ab700 (LWP 5462)]

(emacs:5458): GLib-GIO-CRITICAL **: g_settings_schema_source_lookup: assertion 'source != NULL' failed
 

When this breakpoint breaks, type:

  (gdb) disable
  (gdb) print s->f->terminal->image_cache->images[0]
  (gdb) watch -l s->f->terminal->image_cache->images[0] if s->f->terminal->image_cache->images[0] == 0
  (gdb) continue

Thread 1 "emacs" hit Breakpoint 3, fill_image_glyph_string (
    s=s@entry=0x7fffffff8f10) at xdisp.c:26151
26151   {
(gdb) disable
(gdb) print s->f->terminal->image_cache->images[0]
$1 = (struct image *) 0x42a70b0
(gdb) watch -l s->f->terminal->image_cache->images[0] if s->f->terminal->image_cache->images[0] == 0
Hardware watchpoint 4: -location s->f->terminal->image_cache->images[0]
(gdb) continue
Continuing.
 
Then invoke the rest of your recipe.  (It could be that the breakpoint
breaks only after you invoke the last two lines of the recipe.)

warning: Watchpoint condition cannot be tested in the current scope

Thread 1 "emacs" hit Hardware watchpoint 4: -location s->f->terminal->image_cache->images[0]

Old value = (struct image *) 0x42a70b0
New value = (struct image *) 0x0
free_image (f=f@entry=0x143b260, img=img@entry=0x42a70b0) at image.c:1022
1022          if (img->picture)
 
Each time the watchpoint breaks, type

 (gdb) bt

(gdb) bt
#0  free_image (f=f@entry=0x143b260, img=img@entry=0x42a70b0) at image.c:1022
#1  0x00000000006646a1 in clear_image_cache (f=0x143b260,
    filter=filter@entry=XIL(0xc5a0)) at image.c:1574
#2  0x000000000066a35d in Fclear_image_cache (filter=...) at image.c:1658
#3  0x00000000005cf848 in funcall_subr (subr=0xceadc0 <Sclear_image_cache>,
    numargs=numargs@entry=0, args=args@entry=0x7fffffff0650) at eval.c:2935
#4  0x00000000005cdc27 in Ffuncall (nargs=1, args=args@entry=0x7fffffff0648)
    at eval.c:2860
#5  0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x4d70415), maxdepth=..., maxdepth@entry=make_number(17),
    args_template=..., args_template@entry=make_number(1024),
    nargs=nargs@entry=0, args=<optimized out>, args@entry=0x7fffffff0a88)
    at bytecode.c:633
#6  0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x4d70635),
    nargs=nargs@entry=0, arg_vector=arg_vector@entry=0x7fffffff0a88)
    at eval.c:3058
#7  0x00000000005cdd80 in Ffuncall (nargs=1, args=args@entry=0x7fffffff0a80)
    at eval.c:2862
#8  0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x4ce79c5), maxdepth=..., maxdepth@entry=make_number(7),
    args_template=..., args_template@entry=make_number(0),
    nargs=nargs@entry=0, args=<optimized out>, args@entry=0x7fffffff1020)
    at bytecode.c:633
#9  0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x4ce6925),
    nargs=nargs@entry=0, arg_vector=arg_vector@entry=0x7fffffff1020)
    at eval.c:3058
#10 0x00000000005cdd80 in Ffuncall (nargs=1, args=args@entry=0x7fffffff1018)
    at eval.c:2862
#11 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
---Type <return> to continue, or q <return> to quit---
    vector@entry=XIL(0x7ffff32d538d), maxdepth=...,
    maxdepth@entry=make_number(5), args_template=...,
    args_template@entry=make_number(513), nargs=nargs@entry=2,
    args=<optimized out>, args@entry=0x7fffffff1308) at bytecode.c:633
#12 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff32d535d),
    nargs=nargs@entry=2, arg_vector=arg_vector@entry=0x7fffffff1308)
    at eval.c:3058
#13 0x00000000005cdd80 in Ffuncall (nargs=3, args=args@entry=0x7fffffff1300)
    at eval.c:2862
#14 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x7ffff31de765), maxdepth=...,
    maxdepth@entry=make_number(13), args_template=...,
    args_template@entry=make_number(256), nargs=nargs@entry=0,
    args=<optimized out>, args@entry=0x7fffffff17d0) at bytecode.c:633
#15 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff31de735),
    nargs=nargs@entry=0, arg_vector=arg_vector@entry=0x7fffffff17d0)
    at eval.c:3058
#16 0x00000000005cdd80 in Ffuncall (nargs=1, args=args@entry=0x7fffffff17c8)
    at eval.c:2862
#17 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x60373e5), maxdepth=..., maxdepth@entry=make_number(16),
    args_template=..., args_template@entry=make_number(1026),
    nargs=nargs@entry=4, args=<optimized out>, args@entry=0x7fffffff1bb0)
    at bytecode.c:633
#18 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x60374e5),
    nargs=nargs@entry=4, arg_vector=arg_vector@entry=0x7fffffff1bb0)
    at eval.c:3058
#19 0x00000000005cdd80 in Ffuncall (nargs=5, args=args@entry=0x7fffffff1ba8)
    at eval.c:2862
---Type <return> to continue, or q <return> to quit---
#20 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x3e55fd5), maxdepth=..., maxdepth@entry=make_number(18),
    args_template=..., args_template@entry=make_number(771),
    nargs=nargs@entry=3, args=<optimized out>, args@entry=0x7fffffff2130)
    at bytecode.c:633
#21 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x3e55365),
    nargs=nargs@entry=3, arg_vector=arg_vector@entry=0x7fffffff2130)
    at eval.c:3058
#22 0x00000000005cdd80 in Ffuncall (nargs=4, args=args@entry=0x7fffffff2128)
    at eval.c:2862
#23 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x3e549b5), maxdepth=..., maxdepth@entry=make_number(6),
    args_template=..., args_template@entry=make_number(514),
    nargs=nargs@entry=2, args=<optimized out>, args@entry=0x7fffffff23f0)
    at bytecode.c:633
#24 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x3e549d5),
    nargs=nargs@entry=2, arg_vector=arg_vector@entry=0x7fffffff23f0)
    at eval.c:3058
#25 0x00000000005cdd80 in Ffuncall (nargs=3, args=args@entry=0x7fffffff23e8)
    at eval.c:2862
#26 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x3e54895), maxdepth=..., maxdepth@entry=make_number(9),
    args_template=..., args_template@entry=make_number(257),
    nargs=nargs@entry=1, args=<optimized out>, args@entry=0x7fffffff2788)
    at bytecode.c:633
#27 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x3e54945),
    nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7fffffff2788)
    at eval.c:3058
#28 0x00000000005cdd80 in Ffuncall (nargs=2, args=args@entry=0x7fffffff2780)
---Type <return> to continue, or q <return> to quit---
    at eval.c:2862
#29 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x7ffff323e465), maxdepth=...,
    maxdepth@entry=make_number(30), args_template=...,
    args_template@entry=make_number(770), nargs=nargs@entry=3,
    args=<optimized out>, args@entry=0x7fffffff2d40) at bytecode.c:633
#30 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff323e435),
    nargs=nargs@entry=3, arg_vector=arg_vector@entry=0x7fffffff2d40)
    at eval.c:3058
#31 0x00000000005cdd80 in Ffuncall (nargs=4, args=args@entry=0x7fffffff2d38)
    at eval.c:2862
#32 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x7ffff323da15), maxdepth=...,
    maxdepth@entry=make_number(14), args_template=...,
    args_template@entry=make_number(771), nargs=nargs@entry=3,
    args=<optimized out>, args@entry=0x7fffffff30b8) at bytecode.c:633
#33 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff323d9e5),
    nargs=nargs@entry=3, arg_vector=arg_vector@entry=0x7fffffff30b8)
    at eval.c:3058
#34 0x00000000005cdd80 in Ffuncall (nargs=4, args=args@entry=0x7fffffff30b0)
    at eval.c:2862
#35 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x7ffff323d94d), maxdepth=...,
    maxdepth@entry=make_number(7), args_template=...,
    args_template@entry=make_number(770), nargs=nargs@entry=2,
    args=<optimized out>, args@entry=0x7fffffff3358) at bytecode.c:633
#36 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff323d91d),
    nargs=nargs@entry=2, arg_vector=arg_vector@entry=0x7fffffff3358)
    at eval.c:3058
---Type <return> to continue, or q <return> to quit---
#37 0x00000000005cdd80 in Ffuncall (nargs=3, args=args@entry=0x7fffffff3350)
    at eval.c:2862
#38 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x1c09dd5), maxdepth=..., maxdepth@entry=make_number(10),
    args_template=..., args_template@entry=make_number(257),
    nargs=nargs@entry=1, args=<optimized out>, args@entry=0x7fffffff37a8)
    at bytecode.c:633
#39 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x1c09e25),
    nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7fffffff37a8)
    at eval.c:3058
#40 0x00000000005cdd80 in Ffuncall (nargs=2, args=args@entry=0x7fffffff37a0)
    at eval.c:2862
#41 0x00000000005cdff9 in run_hook_wrapped_funcall (nargs=<optimized out>,
    args=0x7fffffff37a0) at eval.c:2587
#42 0x00000000005cd341 in run_hook_with_args (nargs=2, args=0x7fffffff37a0,
    funcall=funcall@entry=0x5cdfdd <run_hook_wrapped_funcall>) at eval.c:2668
#43 0x00000000005cd4de in Frun_hook_wrapped (nargs=<optimized out>,
    args=<optimized out>) at eval.c:2602
#44 0x00000000005cf71c in funcall_subr (subr=0xce4ac0 <Srun_hook_wrapped>,
    numargs=numargs@entry=2, args=args@entry=0x7fffffff37a0) at eval.c:2915
#45 0x00000000005cdc27 in Ffuncall (nargs=3, args=args@entry=0x7fffffff3798)
    at eval.c:2860
#46 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x7ffff32e32bd), maxdepth=...,
    maxdepth@entry=make_number(19), args_template=...,
    args_template@entry=make_number(514), nargs=nargs@entry=2,
    args=<optimized out>, args@entry=0x7fffffff3ae0) at bytecode.c:633
#47 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff32e328d),
    nargs=nargs@entry=2, arg_vector=arg_vector@entry=0x7fffffff3ae0)
---Type <return> to continue, or q <return> to quit---
    at eval.c:3058
#48 0x00000000005cdd80 in Ffuncall (nargs=3, args=args@entry=0x7fffffff3ad8)
    at eval.c:2862
#49 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x7ffff32e303d), maxdepth=...,
    maxdepth@entry=make_number(27), args_template=...,
    args_template@entry=make_number(512), nargs=nargs@entry=2,
    args=<optimized out>, args@entry=0x7fffffff3ef8) at bytecode.c:633
#50 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff32e300d),
    nargs=nargs@entry=2, arg_vector=arg_vector@entry=0x7fffffff3ef8)
    at eval.c:3058
#51 0x00000000005cdd80 in Ffuncall (nargs=3, args=args@entry=0x7fffffff3ef0)
    at eval.c:2862
#52 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=...,
    vector@entry=XIL(0x7ffff3352f5d), maxdepth=...,
    maxdepth@entry=make_number(12), args_template=...,
    args_template@entry=make_number(257), nargs=nargs@entry=1,
    args=<optimized out>, args@entry=0x7fffffff4248) at bytecode.c:633
#53 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff3352f2d),
    nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7fffffff4248)
    at eval.c:3058
#54 0x00000000005cdd80 in Ffuncall (nargs=nargs@entry=2,
    args=args@entry=0x7fffffff4240) at eval.c:2862
#55 0x00000000005ccffa in internal_condition_case_n (bfun=0x5cdaef <Ffuncall>,
    nargs=nargs@entry=2, args=args@entry=0x7fffffff4240, handlers=...,
    handlers@entry=XIL(0xc5a0), hfun=hfun@entry=0x4529d5 <safe_eval_handler>)
    at eval.c:1456
#56 0x00000000004455e9 in safe__call (inhibit_quit=inhibit_quit@entry=false,
    nargs=nargs@entry=2, func=XIL(0x7ffff25f1c78), ap=ap@entry=0x7fffffff42b8)
---Type <return> to continue, or q <return> to quit---
    at xdisp.c:2644
#57 0x000000000044dd82 in safe_call (nargs=nargs@entry=2, func=...)
    at xdisp.c:2659
#58 0x000000000044dda3 in safe_call1 (fn=..., fn@entry=XIL(0x7ffff25f1c78),
    arg=..., arg@entry=make_number(1)) at xdisp.c:2670
#59 0x000000000044e068 in handle_fontified_prop (it=0x7fffffff4520)
    at xdisp.c:3914
#60 0x0000000000455bc3 in handle_stop (it=it@entry=0x7fffffff4520)
    at xdisp.c:3480
#61 0x0000000000455c97 in reseat (it=it@entry=0x7fffffff4520, pos=...,
    force_p=force_p@entry=true) at xdisp.c:6673
#62 0x0000000000456563 in init_iterator (it=it@entry=0x7fffffff4520,
    w=w@entry=0x4e72520, charpos=1, bytepos=<optimized out>,
    row=<optimized out>, base_face_id=base_face_id@entry=DEFAULT_FACE_ID)
    at xdisp.c:3095
#63 0x000000000045e6e1 in start_display (it=it@entry=0x7fffffff4520,
    w=w@entry=0x4e72520, pos=...) at xdisp.c:3111
#64 0x0000000000466acf in try_window (window=..., window@entry=XIL(0x4e72525),
    pos=..., flags=flags@entry=1) at xdisp.c:17812
#65 0x000000000047c63b in redisplay_window (window=XIL(0x4e72525),
    just_this_one_p=just_this_one_p@entry=false) at xdisp.c:17265
#66 0x000000000047e247 in redisplay_window_0 (window=...,
    window@entry=XIL(0x4e72525)) at xdisp.c:14993
#67 0x00000000005cce92 in internal_condition_case_1 (
    bfun=bfun@entry=0x47e218 <redisplay_window_0>, arg=...,
    arg@entry=XIL(0x4e72525), handlers=...,
    hfun=hfun@entry=0x43b9ba <redisplay_window_error>) at eval.c:1400
#68 0x000000000043d755 in redisplay_windows (window=...) at xdisp.c:14973
#69 0x000000000043d6f6 in redisplay_windows (window=...) at xdisp.c:14967
---Type <return> to continue, or q <return> to quit---
#70 0x000000000046ce76 in redisplay_internal () at xdisp.c:14443
#71 0x000000000046e493 in redisplay () at xdisp.c:13664
#72 0x000000000054451e in read_char (commandflag=0, map=..., map@entry=XIL(0x47f8093), prev_event=XIL(0x47f8093), used_mouse_menu=used_mouse_menu@entry=0x7fffffff967b, end_time=end_time@entry=0x0)
    at keyboard.c:2462
#73 0x0000000000545f05 in read_key_sequence (keybuf=keybuf@entry=0x7fffffff9750, prompt=..., prompt@entry=XIL(0x3ada394), dont_downcase_last=<optimized out>,
    can_return_switch_frame=can_return_switch_frame@entry=false, fix_current_buffer=fix_current_buffer@entry=false, prevent_redisplay=prevent_redisplay@entry=false) at keyboard.c:9082
#74 0x00000000005489be in read_key_sequence_vs (prompt=..., continue_echo=XIL(0), dont_downcase_last=..., can_return_switch_frame=XIL(0), cmd_loop=..., allow_string=allow_string@entry=false)
    at keyboard.c:9777
#75 0x0000000000548a97 in Fread_key_sequence_vector (prompt=..., continue_echo=..., dont_downcase_last=..., can_return_switch_frame=..., cmd_loop=...) at keyboard.c:9858
#76 0x00000000005cf89c in funcall_subr (subr=0xcdd780 <Sread_key_sequence_vector>, numargs=numargs@entry=3, args=args@entry=0x7fffffff9970) at eval.c:2947
#77 0x00000000005cdc27 in Ffuncall (nargs=4, args=args@entry=0x7fffffff9968) at eval.c:2860
#78 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=..., vector@entry=XIL(0x7ffff31fe77d), maxdepth=..., maxdepth@entry=make_number(14), args_template=...,
    args_template@entry=make_number(256), nargs=nargs@entry=1, args=<optimized out>, args@entry=0x7fffffff9ca0) at bytecode.c:633
#79 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff31fe74d), nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7fffffff9ca0) at eval.c:3058
#80 0x00000000005cdd80 in Ffuncall (nargs=2, args=args@entry=0x7fffffff9c98) at eval.c:2862
#81 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=..., vector@entry=XIL(0x7ffff319f95d), maxdepth=..., maxdepth@entry=make_number(9), args_template=..., args_template@entry=make_number(257),
    nargs=nargs@entry=1, args=<optimized out>, args@entry=0x7fffffffa0a0) at bytecode.c:633
#82 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff319f92d), nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7fffffffa0a0) at eval.c:3058
#83 0x00000000005cdd80 in Ffuncall (nargs=2, args=args@entry=0x7fffffffa098) at eval.c:2862
#84 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=..., vector@entry=XIL(0x603b905), maxdepth=..., maxdepth@entry=make_number(14), args_template=..., args_template@entry=make_number(0),
    nargs=nargs@entry=0, args=<optimized out>, args@entry=0x7fffffffa620) at bytecode.c:633
#85 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x603ba45), nargs=nargs@entry=0, arg_vector=arg_vector@entry=0x7fffffffa620) at eval.c:3058
#86 0x00000000005cdd80 in Ffuncall (nargs=nargs@entry=1, args=args@entry=0x7fffffffa618) at eval.c:2862
#87 0x00000000005c91cb in Ffuncall_interactively (nargs=1, args=0x7fffffffa618) at callint.c:253
#88 0x00000000005cf71c in funcall_subr (subr=0xce4780 <Sfuncall_interactively>, numargs=numargs@entry=1, args=args@entry=0x7fffffffa618) at eval.c:2915
#89 0x00000000005cdc27 in Ffuncall (nargs=nargs@entry=2, args=args@entry=0x7fffffffa610) at eval.c:2860
#90 0x00000000005ce16c in Fapply (nargs=nargs@entry=3, args=args@entry=0x7fffffffa610) at eval.c:2433
#91 0x00000000005c9a0a in Fcall_interactively (function=..., record_flag=..., keys=...) at callint.c:340
#92 0x00000000005cf86a in funcall_subr (subr=0xce4740 <Scall_interactively>, numargs=numargs@entry=3, args=args@entry=0x7fffffffa750) at eval.c:2940
#93 0x00000000005cdc27 in Ffuncall (nargs=4, args=args@entry=0x7fffffffa748) at eval.c:2860
#94 0x000000000060f0bb in exec_byte_code (bytestr=..., vector=..., vector@entry=XIL(0x7ffff32a25a5), maxdepth=..., maxdepth@entry=make_number(13), args_template=...,
    args_template@entry=make_number(1025), nargs=nargs@entry=1, args=<optimized out>, args@entry=0x7fffffffaa78) at bytecode.c:633
#95 0x00000000005d0e5b in funcall_lambda (fun=fun@entry=XIL(0x7ffff32a2575), nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7fffffffaa78) at eval.c:3058
#96 0x00000000005cdd80 in Ffuncall (nargs=nargs@entry=2, args=args@entry=0x7fffffffaa70) at eval.c:2862
#97 0x00000000005ce041 in call1 (fn=..., fn@entry=XIL(0x4020), arg1=...) at eval.c:2711
#98 0x0000000000547999 in command_loop_1 () at keyboard.c:1462
#99 0x00000000005ccded in internal_condition_case (bfun=bfun@entry=0x5473a3 <command_loop_1>, handlers=..., handlers@entry=XIL(0x5490), hfun=hfun@entry=0x53c25f <cmd_error>) at eval.c:1376
#100 0x0000000000537c9a in command_loop_2 (ignore=..., ignore@entry=XIL(0)) at keyboard.c:1090
#101 0x00000000005ccd35 in internal_catch (tag=..., func=func@entry=0x537c82 <command_loop_2>, arg=..., arg@entry=XIL(0)) at eval.c:1139
#102 0x000000000053addd in command_loop () at keyboard.c:1069
#103 0x000000000053bcff in recursive_edit_1 () at keyboard.c:714
#104 0x000000000053c061 in Frecursive_edit () at keyboard.c:785
#105 0x0000000000534efa in main (argc=1, argv=<optimized out>) at emacs.c:1949

Lisp Backtrace:
"clear-image-cache" (0xffff0650)
"org-display-inline-images" (0xffff0a88)
"org-mode" (0xffff1020)
"set-auto-mode-0" (0xffff1308)
"set-auto-mode" (0xffff17d0)
"vc-find-revision-no-save" (0xffff1bb0)
---Type <return> to continue, or q <return> to quit---
"diff-syntax-fontify-hunk" (0xffff2130)
"diff-syntax-fontify" (0xffff23f0)
"diff--font-lock-syntax" (0xffff2788)
"font-lock-fontify-keywords-region" (0xffff2d40)
"font-lock-default-fontify-region" (0xffff30b8)
"font-lock-fontify-region" (0xffff3358)
0x1c09e20 PVEC_COMPILED
"run-hook-wrapped" (0xffff37a0)
"jit-lock--run-functions" (0xffff3ae0)
"jit-lock-fontify-now" (0xffff3ef8)
"jit-lock-function" (0xffff4248)
"redisplay_internal (C function)" (0x0)
"read-key-sequence-vector" (0xffff9970)
"read-key" (0xffff9ca0)
"yes-or-no-p" (0xffffa0a0)
"vc-revert" (0xffffa620)
"funcall-interactively" (0xffffa618)
"call-interactively" (0xffffa750)
"command-execute" (0xffffaa78)
(gdb) continue
Continuing.
warning: Watchpoint condition cannot be tested in the current scope

Thread 1 "emacs" hit Hardware watchpoint 4: -location s->f->terminal->image_cache->images[0]

Old value = (struct image *) 0x0
New value = (struct image *) 0x1f089b0
cache_image (f=f@entry=0x143b260, img=img@entry=0x1f089b0) at image.c:2044
2044      img->id = i;

The result should include the Lisp backtrace as well.  If the "print"
command above shows that images[0] is already NULL, type "bt" right
there and then, before continuing with the rest.

Each time the watchpoint breaks, type "continue" until the program
segfaults, I want to see all the cases where the image in the cache
gets nullified.

Interestingly, the segfault did not happen when I set that breakpoint and proceeded as you suggested, as you see above.

But I killed that gdb session and started again, redid steps to create and crash and got the segfault again:

(gdb) r
Starting program: /home/kmodi/downloads/git/emacs/src/emacs
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffec3ab700 (LWP 8054)]

(emacs:8050): GLib-GIO-CRITICAL **: g_settings_schema_source_lookup: assertion 'source != NULL' failed

xdisp.c:26154: Emacs fatal error: assertion failed: s->img

Thread 1 "emacs" hit Breakpoint 1, terminate_due_to_signal (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=2147483647) at emacs.c:370
370     {
(gdb) bt
#0  terminate_due_to_signal (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=2147483647) at emacs.c:370
#1  0x00000000005a1622 in die (msg=msg@entry=0x67dc2c "s->img", file=file@entry=0x67dbaa "xdisp.c", line=line@entry=26154) at alloc.c:7453
#2  0x00000000004378fe in fill_image_glyph_string (s=s@entry=0x7fffffff7aa0) at xdisp.c:26154
#3  0x00000000004708cf in draw_glyphs (w=w@entry=0x13fa500, x=44, row=0x3c6a390, area=area@entry=TEXT_AREA, start=<optimized out>, start@entry=0, end=end@entry=6, hl=DRAW_NORMAL_TEXT, overlaps=0)
    at xdisp.c:26841
#4  0x0000000000474bd2 in x_write_glyphs (w=0x13fa500, updated_row=<optimized out>, start=<optimized out>, updated_area=TEXT_AREA, len=6) at xdisp.c:29042