Subject: Re: bug#66416: 29.1; pgtk build crashes due to ftcrfont

From: Eli Zaretskii <[email-masked]>
Date: Tue, 16 Apr 2024 15:16:01 +0300

> From: Björn Bidar <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  [email-masked],  [email-masked]
> Date: Tue, 16 Apr 2024 03:27:10 +0300
> 
> I'm not 100% sure if the crash I got is related but today I got a very similar backtrace
> but with the X11/Gtk build.
> Breakpoint 1 at 0x55fb2cc11ebd: file ../../emacs-30.0.50.5934.0fab2649e28/src/emacs.c, line 441.
> Breakpoint 2 at 0x55fb2cd23c00: file ../../emacs-30.0.50.5987.9a79db506e3/src/xterm.c, line 26990.
> #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
> #1  0x00007f510aa94a73 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
> #2  0x00007f510aa41176 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
> #3  0x000055fb2cc11f70 in terminate_due_to_signal (sig=6, backtrace_limit=<optimized out>) at ../../emacs-30.0.50.5934.0fab2649e28/src/emacs.c:479
> #4  0x000055fb2cc1261c in emacs_abort () at ../../emacs-30.0.50.5934.0fab2649e28/src/sysdep.c:2391
> #5  0x000055fb2cc0e742 in redisplay_internal () at ../../emacs-30.0.50.5934.0fab2649e28/src/xdisp.c:16869
> #6  0x000055fb2cc5f26a in redisplay_preserve_echo_area (from_where=<optimized out>) at ../../emacs-30.0.50.5934.0fab2649e28/src/xdisp.c:17740
> #7  0x000055fb2ce5c5eb in Fdelete_process (process=XIL(0x55fc70bb3075)) at ../../emacs-30.0.50.5934.0fab2649e28/src/process.c:1146
> #8  0x000055fb2ce69cd5 in kill_buffer_processes (buffer=XIL(0)) at ../../emacs-30.0.50.5934.0fab2649e28/src/process.c:8288
> #9  0x000055fb2cd588fa in shut_down_emacs (sig=sig@entry=6, stuff=stuff@entry=XIL(0)) at ../../emacs-30.0.50.5934.0fab2649e28/src/emacs.c:3104
> #10 0x000055fb2cc11f3c in terminate_due_to_signal (sig=6, backtrace_limit=40) at ../../emacs-30.0.50.5934.0fab2649e28/src/emacs.c:462
> #11 0x000055fb2cc1261c in emacs_abort () at ../../emacs-30.0.50.5934.0fab2649e28/src/sysdep.c:2391
> #12 0x000055fb2cc0e742 in redisplay_internal () at ../../emacs-30.0.50.5934.0fab2649e28/src/xdisp.c:16869
> #13 0x000055fb2cc5f26a in redisplay_preserve_echo_area (from_where=<optimized out>) at ../../emacs-30.0.50.5934.0fab2649e28/src/xdisp.c:17740
> #14 0x000055fb2ce5c5eb in Fdelete_process (process=XIL(0x55fcae60bef5)) at ../../emacs-30.0.50.5934.0fab2649e28/src/process.c:1146
> #15 0x000055fb2ce69cd5 in kill_buffer_processes (buffer=XIL(0)) at ../../emacs-30.0.50.5934.0fab2649e28/src/process.c:8288
> #16 0x000055fb2cd588fa in shut_down_emacs (sig=0, stuff=XIL(0)) at ../../emacs-30.0.50.5934.0fab2649e28/src/emacs.c:3104
> #17 0x000055fb2cd23937 in x_connection_closed (dpy=<optimized out>, error_message=<optimized out>, ioerror=<optimized out>) at ../../emacs-30.0.50.5987.9a79db506e3/src/xterm.c:26819
> #18 0x000055fb2cd23c8a in x_error_quitter (display=0x55fb3ad0aa90, event=0x7ffdeb3a9570) at ../../emacs-30.0.50.5987.9a79db506e3/src/xterm.c:27013
> #19 0x000055fb2cd2415b in x_error_handler (display=0x55fb3ad0aa90, event=0x7ffdeb3a9570) at ../../emacs-30.0.50.5987.9a79db506e3/src/xterm.c:26978
> #20 0x00007f511519e3ab in _XError () at /lib64/libX11.so.6
> #21 0x00007f511519e4a7 in  () at /lib64/libX11.so.6
> #22 0x00007f511519e55d in  () at /lib64/libX11.so.6
> #23 0x00007f511519e5e2 in _XEventsQueued () at /lib64/libX11.so.6
> #24 0x00007f511519e985 in _XGetRequest () at /lib64/libX11.so.6
> #25 0x00007f511511bff8 in XRenderCompositeText16 () at /lib64/libXrender.so.1
> #26 0x00007f5115744c68 in  () at /lib64/libcairo.so.2
> #27 0x00007f5115703a8d in  () at /lib64/libcairo.so.2
> #28 0x00007f51156c9d87 in  () at /lib64/libcairo.so.2
> #29 0x00007f51156ca330 in  () at /lib64/libcairo.so.2
> #30 0x00007f5115676a31 in  () at /lib64/libcairo.so.2
> #31 0x00007f511570d430 in  () at /lib64/libcairo.so.2
> #32 0x00007f51156c9021 in  () at /lib64/libcairo.so.2
> #33 0x00007f51156854cf in  () at /lib64/libcairo.so.2
> #34 0x00007f51156d11c2 in cairo_show_glyphs () at /lib64/libcairo.so.2
> #35 0x000055fb2ceb3cce in ftcrfont_draw (s=0x7ffdeb3ae680, from=<optimized out>, to=<optimized out>, x=<optimized out>, y=<optimized out>, with_background=<optimized out>) at ../../emacs-30.0.50.5934.0fab2649e28/src/ftcrfont.c:622
> #36 0x000055fb2cd07e4d in x_draw_glyph_string_foreground (s=s@entry=0x7ffdeb3ae680) at ../../emacs-30.0.50.5987.9a79db506e3/src/xterm.c:8642
> #37 0x000055fb2cd0c3ea in x_draw_glyph_string (s=0x7ffdeb3ae680) at ../../emacs-30.0.50.5987.9a79db506e3/src/xterm.c:10912
> #38 0x000055fb2cc77064 in draw_glyphs (w=<optimized out>, x=1899, row=<optimized out>, area=<optimized out>, start=<optimized out>, end=<optimized out>, hl=<optimized out>, overlaps=<optimized out>) at ../../emacs-30.0.50.5934.0fab2649e28/src/xdisp.c:31204
> #39 0x000055fb2cc81f23 in gui_write_glyphs (w=0x55fcb07d2f28, updated_row=<optimized out>, start=<optimized out>, updated_area=TEXT_AREA, len=105) at ../../emacs-30.0.50.5934.0fab2649e28/src/xdisp.c:33346
> #40 0x000055fb2cc1dad1 in update_text_area (partial_p=<synthetic pointer>, vpos=955, updated_row=0x55fc6b5c6290, w=0x55fcb07d2f28) at ../../emacs-30.0.50.5934.0fab2649e28/src/dispnew.c:4033
> #41 update_window_line (w=w@entry=0x55fcb07d2f28, vpos=955, mouse_face_overwritten_p=mouse_face_overwritten_p@entry=0x7ffdeb3aee47) at ../../emacs-30.0.50.5934.0fab2649e28/src/dispnew.c:4291
> #42 0x000055fb2cc249ff in update_window (w=w@entry=0x55fcb07d2f28, force_p=force_p@entry=true) at ../../emacs-30.0.50.5934.0fab2649e28/src/dispnew.c:3718
> #43 0x000055fb2cc25f2b in update_window_tree (w=w@entry=0x55fcb07d2f28, force_p=force_p@entry=true) at ../../emacs-30.0.50.5934.0fab2649e28/src/dispnew.c:3488
> #44 0x000055fb2cc26c9d in update_frame (f=0x55fcb07d2cb0, force_p=true, inhibit_hairy_id_p=<optimized out>) at ../../emacs-30.0.50.5934.0fab2649e28/src/dispnew.c:3323
> #45 0x000055fb2cc5dcc4 in redisplay_internal () at ../../emacs-30.0.50.5934.0fab2649e28/src/xdisp.c:17461
> #46 0x000055fb2cd61b0f in redisplay () at ../../emacs-30.0.50.5934.0fab2649e28/src/xdisp.c:16562
> #47 read_char (commandflag=1, map=XIL(0x55fb30a6ce13), prev_event=XIL(0), used_mouse_menu=0x7ffdeb3b09eb, end_time=0x0) at ../../emacs-30.0.50.5987.9a79db506e3/src/keyboard.c:2677
> #48 0x000055fb2cd739ef in read_key_sequence (keybuf=0x7ffdeb3b0b80, prompt=XIL(0), dont_downcase_last=false, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=false, disable_text_conversion_p=false) at ../../emacs-30.0.50.5987.9a79db506e3/src/keyboard.c:10722
> #49 0x000055fb2cd5ad97 in command_loop_1 () at ../../emacs-30.0.50.5987.9a79db506e3/src/keyboard.c:1428
> #50 0x000055fb2cdf7d07 in internal_condition_case (bfun=0x55fb2cd5abc0 <command_loop_1>, handlers=<optimized out>, hfun=0x55fb2cd59ca0 <cmd_error>) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:1537
> #51 0x000055fb2cd5a0de in command_loop_2 (handlers=handlers@entry=XIL(0x90)) at ../../emacs-30.0.50.5987.9a79db506e3/src/keyboard.c:1167
> #52 0x000055fb2cdf7c11 in internal_catch (tag=<optimized out>, func=0x55fb2cd5a0b0 <command_loop_2>, arg=XIL(0x90)) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:1217
> #53 0x000055fb2cd58bef in command_loop () at ../../emacs-30.0.50.5987.9a79db506e3/src/keyboard.c:1137
> #54 0x000055fb2cd59786 in recursive_edit_1 () at ../../emacs-30.0.50.5987.9a79db506e3/src/keyboard.c:753
> #55 0x000055fb2cd59b9c in Frecursive_edit () at ../../emacs-30.0.50.5987.9a79db506e3/src/keyboard.c:836
> #56 0x000055fb2cdfb24d in funcall_subr (subr=0x55fb2d44d7c0 <Srecursive_edit>, numargs=numargs@entry=0, args=args@entry=0x7ffdeb3b0fa0) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:3088
> #57 0x000055fb2cdf8820 in funcall_general (fun=<optimized out>, numargs=numargs@entry=0, args=args@entry=0x7ffdeb3b0fa0) at ../../emacs-30.0.50.5987.9a79db506e3/src/lisp.h:2242
> #58 0x000055fb2cdf8a16 in Ffuncall (nargs=1, args=0x7ffdeb3b0f98) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:3022
> #59 0x00007f51023f58f6 in F6465627567_debug_0 () at /usr/lib64/emacs/30.0.50/native-lisp/30.0.50-fe1371f1/debug-bee52b4d-b0c8a741.eln
> #60 0x000055fb2cdfb0fc in funcall_subr (subr=0x55fb349e9ad8, numargs=numargs@entry=2, args=args@entry=0x7ffdeb3b1108) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:3113
> #61 0x000055fb2cdf8820 in funcall_general (fun=<optimized out>, numargs=numargs@entry=2, args=args@entry=0x7ffdeb3b1108) at ../../emacs-30.0.50.5987.9a79db506e3/src/lisp.h:2242
> #62 0x000055fb2cdf8a16 in Ffuncall (nargs=nargs@entry=3, args=0x7ffdeb3b1100) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:3022
> #63 0x000055fb2cdf8e80 in Fapply (nargs=nargs@entry=2, args=args@entry=0x7ffdeb3b11b0) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:2693
> #64 0x000055fb2cdf9408 in apply1 (arg=XIL(0x55fb5213abe3), fn=<optimized out>) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:2907
> #65 call_debugger (arg=XIL(0x55fb5213abe3)) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:310
> #66 0x000055fb2cdf9cd5 in maybe_call_debugger (error=XIL(0x55fb5213ac13), conditions=XIL(0x7f5106d91a03)) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:2051
> #67 signal_or_quit (error_symbol=<optimized out>, data=<optimized out>, continuable=continuable@entry=false) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:1876
> #68 0x000055fb2cc15245 in Fsignal (error_symbol=<optimized out>, error_symbol@entry=XIL(0x12db0), data=<optimized out>) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:1746
> #69 0x000055fb2cc15463 in xsignal (data=<optimized out>, error_symbol=XIL(0x12db0)) at ../../emacs-30.0.50.5987.9a79db506e3/src/lisp.h:4808
> #70 xsignal2 (error_symbol=XIL(0x12db0), arg1=<optimized out>, arg2=<optimized out>) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:1912
> #71 0x000055fb2cc1435b in wrong_type_argument (predicate=<optimized out>, value=<optimized out>) at ../../emacs-30.0.50.5934.0fab2649e28/src/data.c:142
> #72 0x000055fb2cc16e84 in check_obarray_slow (obarray=<optimized out>) at /usr/src/debug/emacs-30.0.50.5990.9b755244bf0/src/lread.c:4914
> #73 0x000055fb2ce36467 in check_obarray (obarray=XIL(0x55fc40b4ea8d)) at ../../emacs-30.0.50.5934.0fab2649e28/src/lisp.h:2465
> #74 Fintern (string=XIL(0x55fb52250fe4), obarray=<optimized out>) at /usr/src/debug/emacs-30.0.50.5990.9b755244bf0/src/lread.c:5034
> #75 0x000055fb2cdfb15d in funcall_subr (subr=0x55fb2d45dea0 <Sintern>, numargs=numargs@entry=2, args=args@entry=0x7ffdeb3b1448) at ../../emacs-30.0.50.5987.9a79db506e3/src/eval.c:3092

The above backtrace seems to tell the following story:

  . Emacs loaded some package
  . loading the package triggered its processing (including loading of
    some other package)
  . eventually, as part of processing the loaded packages, Emacs
    called 'intern' (frame #74), which called check_obarray, which
    signaled a wrong-type-argument error (frame #71)
  . the error handling called the Lisp debugger
  . the debugger caused redisplay, which called cairo_show_glyphs,
    which caused an X error (frame #19)
  . the X error caused the X connection to close
  . Emacs then tried to shut down in an orderly fashion, which again
    triggered redisplay, which aborted (most probably because
    X-related data structures are invalid, due to the closed X
    connection)

I suspect that the error we tried to signal in frame #71 has something
to do with the recent changes in obarray handling, with which the
package that is being loaded here does not comply.  So I added Mattias
to the discussion.

I also see that we detect recursive invocations of redisplay too late,
so I have now fixed that on master.

As for the cause of this -- some problem in ftcrfont_draw -- maybe Po
Lu can suggest some ideas.  I guess we should try to understand what
kind of X error was caused here?