Subject: bug#45511: 27.1; Emacs crashes in gui_produce_glyphs when using a custom function for org-roam-insert

From: Maikol Solís <[email-masked]>
Date: Mon, 28 Dec 2020 12:42:08 -0600

Hi Eli,

My emacs is the compiled in the editor's repo for 15.2 (
https://build.opensuse.org/package/show/editors/emacs), so I haven't any
control on how it was compiled.

With respect to the bug, I could reproduce it when I tried to replace a
link in org-roam. Here it is the full backtrace.

Thread 1 "emacs-gtk" received signal SIGSEGV, Segmentation fault.
gui_produce_glyphs (it=0x7ffd8df127a0) at xdisp.c:29925
29925         struct font *font = face->font;
(gdb) source /etc/gdbinit
(gdb) bt
#0  0x00000000004693ed in gui_produce_glyphs (it=0x7ffd8df127a0) at
xdisp.c:29925
#1  0x000000000044d632 in maybe_produce_line_number
(it=it@entry=0x7ffd8df16260)
at xdisp.c:22909
#2  0x000000000045a0ee in display_line (it=it@entry=0x7ffd8df16260,
cursor_vpos=cursor_vpos@entry=1) at xdisp.c:23161
#3  0x000000000045e00d in try_window (window=0x234d765, pos=...,
flags=<optimized out>) at xdisp.c:19182
#4  0x0000000000472e48 in redisplay_window (window=0x234d765,
just_this_one_p=just_this_one_p@entry=false) at xdisp.c:18600
#5  0x000000000047617b in redisplay_window_0 (window=window@entry=0x234d765)
at xdisp.c:16314
#6  0x0000000000574f16 in internal_condition_case_1 (bfun=0x476150
<redisplay_window_0>, arg=0x234d765, handlers=<optimized out>,
hfun=0x437840 <redisplay_window_error>) at eval.c:1380
#7  0x000000000044107c in redisplay_windows (window=0x234d765) at
xdisp.c:16294
#8  0x000000000044108d in redisplay_windows (window=0xf8e2c45) at
xdisp.c:16288
#9  0x0000000000461b78 in redisplay_internal () at xdisp.c:15762
#10 0x000000000046394d in redisplay_preserve_echo_area
(from_where=from_where@entry=7) at xdisp.c:16115
#11 0x00000000005051aa in swallow_events (do_display=do_display@entry=true)
at keyboard.c:4146
#12 0x000000000042c082 in sit_for (timeout=timeout@entry=0x7a,
reading=reading@entry=true, display_option=display_option@entry=1) at
dispnew.c:6006
#13 0x000000000050ae48 in read_char (commandflag=commandflag@entry=1,
map=map@entry=0x45f8433, prev_event=0x0,
used_mouse_menu=used_mouse_menu@entry=0x7ffd8df1b84b,
end_time=end_time@entry=0x0) at keyboard.c:2738
#14 0x000000000050b290 in read_key_sequence
   (keybuf=keybuf@entry=0x7ffd8df1b950, prompt=prompt@entry=0x0,
dont_downcase_last=dont_downcase_last@entry=false,
can_return_switch_frame=can_return_switch_frame@entry=true,
fix_current_buffer=fix_current_buffer@entry=true, prevent_re
display=prevent_redisplay@entry=false) at keyboard.c:9553
#15 0x000000000050c8fe in command_loop_1 () at keyboard.c:1350
#16 0x0000000000574e7e in internal_condition_case (bfun=bfun@entry=0x50c700
<command_loop_1>, handlers=handlers@entry=0x90, hfun=hfun@entry=0x503780
<cmd_error>) at eval.c:1356
#17 0x00000000004fe1bc in command_loop_2 (ignore=ignore@entry=0x0) at
keyboard.c:1091
#18 0x0000000000574ded in internal_catch (tag=tag@entry=0x5bb0,
func=func@entry=0x4fe1a0 <command_loop_2>, arg=arg@entry=0x0) at eval.c:1117
#19 0x00000000004fe124 in command_loop () at keyboard.c:1062
#20 0x00000000005033b6 in recursive_edit_1 () at keyboard.c:714
#21 0x000000000052bdc2 in read_minibuf (map=map@entry=0x4552933,
initial=<optimized out>, initial@entry=0x0, prompt=<optimized out>,
   prompt@entry=0x3695c44, expflag=<optimized out>, histvar=<optimized
out>, histpos=<optimized out>, defalt=<optimized out>,
allow_props=<optimized out>, inherit_input_method=<optimized out>) at
minibuf.c:664
#22 0x000000000052c57c in Fread_from_minibuffer (prompt=0x3695c44,
initial_contents=0x0, keymap=0x4552933, read=0x0, hist=<optimized out>,
default_value=0x0, inherit_input_method=0x0) at minibuf.c:942
#23 0x0000000000577201 in funcall_subr (subr=0xbc5920
<Sread_from_minibuffer>, numargs=numargs@entry=5,
args=args@entry=0x7ffd8df1bd88)
at eval.c:2893
#24 0x0000000000575c05 in Ffuncall (nargs=6, args=args@entry=0x7ffd8df1bd80)
at eval.c:2795
#25 0x00000000005ab160 in exec_byte_code (bytestr=<optimized out>,
vector=<optimized out>, maxdepth=<optimized out>,
args_template=args_template@entry=0x406, nargs=nargs@entry=1,
args=<optimized out>, args@entry=0x7ffd8df1c028)
   at bytecode.c:633
#26 0x00000000005784dc in funcall_lambda (fun=0x7f68248f3d8d,
nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7ffd8df1c028) at
eval.c:2990
#27 0x0000000000575b5f in Ffuncall (nargs=nargs@entry=2,
args=args@entry=0x7ffd8df1c020)
at eval.c:2809
#28 0x0000000000575cca in call1 (fn=<optimized out>, arg1=arg1@entry=0x3695c64)
at eval.c:2655
#29 0x000000000058276e in do_yes_or_no_p (prompt=0x3695c64) at fns.c:2773
#30 0x000000000051ef96 in Fkill_buffer (buffer_or_name=<optimized out>) at
buffer.c:1739
#31 0x0000000000577236 in funcall_subr (subr=0xbc4da0 <Skill_buffer>,
numargs=numargs@entry=1, args=args@entry=0x7ffd8df1c208) at eval.c:2868
#32 0x0000000000575c05 in Ffuncall (nargs=2, args=args@entry=0x7ffd8df1c200)
at eval.c:2795
#33 0x00000000005ab160 in exec_byte_code (bytestr=<optimized out>,
vector=<optimized out>, maxdepth=<optimized out>,
args_template=args_template@entry=0x80a, nargs=nargs@entry=2,
args=<optimized out>, args@entry=0x7ffd8df1c450)
   at bytecode.c:633
#34 0x00000000005784dc in funcall_lambda (fun=0x6b88445, nargs=nargs@entry=2,
arg_vector=arg_vector@entry=0x7ffd8df1c450) at eval.c:2990
#35 0x0000000000575b5f in Ffuncall (nargs=3, args=args@entry=0x7ffd8df1c448)
at eval.c:2809
#36 0x00000000005ab160 in exec_byte_code (bytestr=<optimized out>,
vector=<optimized out>, maxdepth=<optimized out>,
args_template=args_template@entry=0x402, nargs=nargs@entry=1,
args=<optimized out>, args@entry=0x7ffd8df1c760)
   at bytecode.c:633
#37 0x00000000005784dc in funcall_lambda (fun=0x6b88405, nargs=nargs@entry=1,
arg_vector=arg_vector@entry=0x7ffd8df1c760) at eval.c:2990
#38 0x0000000000575b5f in Ffuncall (nargs=nargs@entry=2,
args=args@entry=0x7ffd8df1c758)
at eval.c:2809
#39 0x0000000000572460 in Ffuncall_interactively (nargs=2,
args=0x7ffd8df1c758) at callint.c:254
#40 0x0000000000577175 in funcall_subr (subr=0xbcaaa0
<Sfuncall_interactively>, numargs=numargs@entry=2,
args=args@entry=0x7ffd8df1c758)
at eval.c:2848
#41 0x0000000000575c05 in Ffuncall (nargs=nargs@entry=3,
args=args@entry=0x7ffd8df1c750)
at eval.c:2795
#42 0x0000000000573040 in Fcall_interactively (function=<optimized out>,
record_flag=<optimized out>, keys=<optimized out>) at callint.c:783
#43 0x000000000057725e in funcall_subr (subr=0xbcaa60
<Scall_interactively>, numargs=numargs@entry=3, args=args@entry=0x7ffd8df1ca20)
at eval.c:2873
#44 0x0000000000575c05 in Ffuncall (nargs=4, args=args@entry=0x7ffd8df1ca18)
at eval.c:2795
#45 0x00000000005ab160 in exec_byte_code (bytestr=<optimized out>,
vector=<optimized out>, maxdepth=<optimized out>,
args_template=args_template@entry=0x1006, nargs=nargs@entry=1,
args=<optimized out>, args@entry=0x7ffd8df1ccb8)
   at bytecode.c:633
#46 0x00000000005784dc in funcall_lambda (fun=0x7f6824a613e5,
nargs=nargs@entry=1, arg_vector=arg_vector@entry=0x7ffd8df1ccb8) at
eval.c:2990
--Type <RET> for more, q to quit, c to continue without paging--
#47 0x0000000000575b5f in Ffuncall (nargs=nargs@entry=2,
args=args@entry=0x7ffd8df1ccb0)
at eval.c:2809
#48 0x0000000000575cca in call1 (fn=fn@entry=0x4380, arg1=<optimized out>)
at eval.c:2655
#49 0x000000000050caf0 in command_loop_1 () at keyboard.c:1463
#50 0x0000000000574e7e in internal_condition_case (bfun=bfun@entry=0x50c700
<command_loop_1>, handlers=handlers@entry=0x90, hfun=hfun@entry=0x503780
<cmd_error>) at eval.c:1356
#51 0x00000000004fe1bc in command_loop_2 (ignore=ignore@entry=0x0) at
keyboard.c:1091
#52 0x0000000000574ded in internal_catch (tag=tag@entry=0xd5c0,
func=func@entry=0x4fe1a0 <command_loop_2>, arg=arg@entry=0x0) at eval.c:1117
#53 0x00000000004fe164 in command_loop () at keyboard.c:1070
#54 0x00000000005033b6 in recursive_edit_1 () at keyboard.c:714
#55 0x00000000005036c4 in Frecursive_edit () at keyboard.c:786
#56 0x0000000000422984 in main (argc=1, argv=0x7ffd8df1d148) at emacs.c:2066

-----
Maikol Solís
Universidad de Costa Rica
Escuela de Matemática
Centro de Investigación en Matemática Pura y Aplicada
Tel: (506) 2511-6607 / (506) 2511-6606

On Mon, Dec 28, 2020 at 11:17 AM Eli Zaretskii <[email-masked]> wrote:

> > From: Maikol Solís <[email-masked]>
> > Date: Mon, 28 Dec 2020 09:32:17 -0600
> >
> > Everything is fine except that after a couple of times using it, emacs
> crashes completely.  I think that is
> > caused by this function because this has never happened before.
> >
> > I used `gdb` to follow the crash and this is the output:
> >
> >      Thread 1 "emacs-gtk" received signal SIGSEGV, Segmentation fault.
>
> Is this a normal build of Emacs, or did you build some branch of the
> Git repository?  (I'm puzzled why the thread is called "emacs-gtk".)
>
> >      gui_produce_glyphs (it=0x7fff82fc3650) at xdisp.c:29925
> >      29925         struct font *font = face->font;
> >      (gdb) next
>
> At this point, please say
>
>    (gdb) source /path/to/emacs/src/.gdbinit
>    (gdb) bt
>
> (replacing "/path/to/emacs" with the real location of the Emacs
> sources on your system) and post the result.
>