Subject: Bug: Emacs 27.1 hangs forever in `FcCharSetSubtractCount' from '/usr/lib/libfontconfig.so.1'

From: Alexander Shukaev <[email-masked]>
Date: Thu, 3 Sep 2020 09:18:53 +0200

Hi,

With latest Emacs, I have a sporadic hang issue when either opening a 
file or scrolling a buffer.  The best part is that it's impossible to 
get break back to evaluation loop of Emacs even with 'USR2' signal. 
That is when 'USR2' is sent, it does show "Entering debugger...", though 
it remains frozen afterwards.  Resending 'USR2' leads to the same 
outcome.  One thing is for certain, every time 'USR2' is sent into such 
a hang, the stack traceback leads to `FcCharSetSubtractCount' from 
'/usr/lib/libfontconfig.so.1':

Thread 1 "emacs" received signal SIGUSR2, User defined signal 2.
0x00007ffff60f8211 in FcCharSetSubtractCount ()
    from /usr/lib/libfontconfig.so.1
(gdb) bt
#0  0x00007ffff60f8211 in FcCharSetSubtractCount
     () at /usr/lib/libfontconfig.so.1
#1  0x00007ffff61057df in  ()
     at /usr/lib/libfontconfig.so.1
#2  0x00007ffff6105c05 in  ()
     at /usr/lib/libfontconfig.so.1
#3  0x00007ffff6105fa7 in  ()
     at /usr/lib/libfontconfig.so.1
#4  0x00007ffff61060b4 in  ()
     at /usr/lib/libfontconfig.so.1
#5  0x00007ffff6106ef8 in FcFontMatch ()
     at /usr/lib/libfontconfig.so.1
#6  0x00005555558e523c in ftcrfont_open
     (f=0x5555563d5f50, entity=..., pixel_size=15)
     at ftcrfont.c:137
#7  0x00005555558466c8 in font_open_entity
     (f=0x5555563d5f50, entity=..., pixel_size=13)
     at font.c:2913
#8  0x0000555555848372 in font_open_for_lface
     (f=0x5555563d5f50, entity=..., attrs=0x55555cd757d0, spec=...) at 
font.c:3350
#9  0x00005555558eaf63 in fontset_find_font
     (fontset=..., c=25253, face=0x55555cd757d0, charset_id=-1, 
fallback=true) at fontset.c:713
#10 0x00005555558eb632 in fontset_font
     (fontset=..., c=25253, face=0x55555cd757d0, id=-1) at fontset.c:806
#11 0x00005555558ec00b in face_for_char
     (f=0x5555563d5f50, face=0x55555cd757d0, c=25253, pos=257429, 
object=...) at fontset.c:996
#12 0x00005555555bd121 in FACE_FOR_CHAR
     (f=0x5555563d5f50, face=0x55555cd757d0, character=25253, 
pos=257429, object=...)
     at dispextern.h:1882
#13 0x00005555555db943 in get_next_display_element (it=0x7ffffffe5290) 
at xdisp.c:7753
#14 0x00005555555df551 in move_it_in_display_line_to
     (it=0x7ffffffe5290, to_charpos=-1, to_x=-1, op=(unknown: 0)) at 
xdisp.c:9244
#15 0x00005555555e291d in move_it_to
     (it=0x7ffffffe5290, to_charpos=-1, to_x=-1, to_y=-1, to_vpos=1, 
op=4) at xdisp.c:9853
#16 0x00005555555e4157 in move_it_by_lines
     (it=0x7ffffffe5290, dvpos=1) at xdisp.c:10386
#17 0x00005555555c1484 in line_bottom_y
     (it=0x7ffffffe5290) at xdisp.c:1451
#18 0x00005555555c257e in pos_visible_p
     (w=0x5555563d6190, charpos=257337, x=0x7ffffffe9f3c, 
y=0x7ffffffe9f38, rtop=0x7ffffffe9f4c, rbot=0x7ffffffe9f48, 
rowh=0x7ffffffe9f44, vpos=0x7ffffffe9f40) at xdisp.c:1753
#19 0x000055555564e225 in Fpos_visible_in_window_p (pos=..., window=..., 
partially=...)
     at window.c:1910
#20 0x0000555555756d97 in Fposn_at_point
     (pos=..., window=...) at keyboard.c:11249
#21 0x000055555582158d in funcall_subr
     (subr=0x555555de5c20 <Sposn_at_point>, numargs=2, 
args=0x7ffffffea1a8) at eval.c:2870
--Type <RET> for more, q to quit, c to continue without paging--
#22 0x0000555555820fc9 in Ffuncall
     (nargs=3, args=0x7ffffffea1a0) at eval.c:2795
#23 0x000055555587d61a in exec_byte_code
     (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, 
args=0x7ffffffea858)
     at bytecode.c:632
#24 0x0000555555821815 in fetch_and_exec_byte_code (fun=..., 
syms_left=..., nargs=1, args=0x7ffffffea850) at eval.c:2917
#25 0x0000555555821cce in funcall_lambda
     (fun=..., nargs=1, arg_vector=0x7ffffffea850)
     at eval.c:2998
#26 0x000055555582100d in Ffuncall
     (nargs=2, args=0x7ffffffea848) at eval.c:2797
#27 0x000055555587d61a in exec_byte_code
     (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=2, 
args=0x7ffffffeae08)
     at bytecode.c:632
#28 0x0000555555821815 in fetch_and_exec_byte_code (fun=..., 
syms_left=..., nargs=2, args=0x7ffffffeadf8) at eval.c:2917
#29 0x0000555555821cce in funcall_lambda
     (fun=..., nargs=2, arg_vector=0x7ffffffeadf8)
     at eval.c:2998
#30 0x000055555582100d in Ffuncall
     (nargs=3, args=0x7ffffffeadf0) at eval.c:2797
#31 0x000055555587d61a in exec_byte_code
     (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=2, 
args=0x7ffffffeb348)
     at bytecode.c:632
#32 0x0000555555821815 in fetch_and_exec_byte_code (fun=..., 
syms_left=..., nargs=2, args=0x7ffffffeb338) at eval.c:2917
#33 0x0000555555821cce in funcall_lambda
     (fun=..., nargs=2, arg_vector=0x7ffffffeb338)
     at eval.c:2998
#34 0x000055555582100d in Ffuncall
     (nargs=3, args=0x7ffffffeb330) at eval.c:2797
#35 0x000055555587d61a in exec_byte_code
     (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=2, 
args=0x7ffffffeb908)
     at bytecode.c:632
#36 0x0000555555821815 in fetch_and_exec_byte_code (fun=..., 
syms_left=..., nargs=2, args=0x7ffffffeb8f8) at eval.c:2917
#37 0x0000555555821cce in funcall_lambda
     (fun=..., nargs=2, arg_vector=0x7ffffffeb8f8)
     at eval.c:2998
#38 0x000055555582100d in Ffuncall
     (nargs=3, args=0x7ffffffeb8f0) at eval.c:2797
#39 0x000055555587d61a in exec_byte_code
     (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=2, 
args=0x7ffffffebf78)
     at bytecode.c:632
#40 0x0000555555821815 in fetch_and_exec_byte_code (fun=..., 
syms_left=..., nargs=2, args=0x7ffffffebf78) at eval.c:2917
#41 0x0000555555821cce in funcall_lambda
     (fun=..., nargs=2, arg_vector=0x7ffffffebf78)
     at eval.c:2998
--Type <RET> for more, q to quit, c to continue without paging--
#42 0x000055555582100d in Ffuncall
     (nargs=3, args=0x7ffffffebf70) at eval.c:2797
#43 0x0000555555820069 in Fapply
     (nargs=2, args=0x7ffffffec020) at eval.c:2425
#44 0x000055555582075e in apply1
     (fn=..., arg=...) at eval.c:2641
#45 0x00005555558194bf in call_debugger (arg=...)
     at eval.c:339
#46 0x000055555581dde8 in maybe_call_debugger
     (conditions=..., sig=..., data=...)
     at eval.c:1831
#47 0x000055555581d689 in signal_or_quit
     (error_symbol=..., data=..., keyboard_quit=true) at eval.c:1667
#48 0x000055555581d350 in quit () at eval.c:1577
#49 0x000055555581d23b in process_quit_flag ()
     at eval.c:1524
#50 0x000055555581d281 in maybe_quit ()
     at eval.c:1544
#51 0x000055555582df32 in Fassq
     (key=..., alist=...) at fns.c:1609
#52 0x00005555556ae6ad in uniprop_table
     (prop=...) at chartab.c:1284
#53 0x00005555557af2aa in prepare_casing_context
     (ctx=0x7ffffffec320, flag=CASE_UP, inbuffer=false) at casefiddle.c:72
#54 0x00005555557afac6 in casify_object
     (flag=CASE_UP, obj=...) at casefiddle.c:326
#55 0x00005555557afb9d in Fupcase (obj=...)
     at casefiddle.c:349
#56 0x000055555582a190 in Fcompare_strings
     (str1=..., start1=..., end1=..., str2=..., start2=..., end2=..., 
ignore_case=...) at fns.c:320
#57 0x00005555557966f2 in Fassoc_string
     (key=..., list=..., case_fold=...)
     at minibuf.c:1855
#58 0x0000555555847bbb in font_find_for_lface
     (f=0x5555563d5f50, attrs=0x55555cd757d0, spec=..., c=-1) at font.c:3250
#59 0x00005555558ead1e in fontset_find_font
     (fontset=..., c=25253, face=0x55555cd757d0, charset_id=-1, 
fallback=true) at fontset.c:660
#60 0x00005555558eb632 in fontset_font
     (fontset=..., c=25253, face=0x55555cd757d0, id=-1) at fontset.c:806
#61 0x00005555558ec00b in face_for_char
     (f=0x5555563d5f50, face=0x55555cd757d0, c=25253, pos=257429, 
object=...) at fontset.c:996
#62 0x00005555555bd121 in FACE_FOR_CHAR
     (f=0x5555563d5f50, face=0x55555cd757d0, character=25253, 
pos=257429, object=...)
     at dispextern.h:1882
#63 0x00005555555db943 in get_next_display_element (it=0x7fffffff5160) 
at xdisp.c:7753
#64 0x00005555555df551 in move_it_in_display_line_to
     (it=0x7fffffff5160, to_charpos=-1, to_x=-1, op=(unknown: 0)) at 
xdisp.c:9244
#65 0x00005555555e291d in move_it_to
     (it=0x7fffffff5160, to_charpos=-1, to_x=-1, to--Type <RET> for 
more, q to quit, c to continue without paging--
_y=-1, to_vpos=1, op=4) at xdisp.c:9853
#66 0x00005555555e4157 in move_it_by_lines
     (it=0x7fffffff5160, dvpos=1) at xdisp.c:10386
#67 0x00005555555c1484 in line_bottom_y
     (it=0x7fffffff5160) at xdisp.c:1451
#68 0x00005555555c257e in pos_visible_p
     (w=0x5555563d6190, charpos=257337, x=0x7fffffff9e20, 
y=0x7fffffff9e1c, rtop=0x7fffffff9e18, rbot=0x7fffffff9e14, 
rowh=0x7fffffff9e10, vpos=0x7fffffff9e0c) at xdisp.c:1753
#69 0x0000555555658633 in window_scroll_pixel_based (window=..., n=1, 
whole=true, noerror=false)
     at window.c:5549
#70 0x00005555556582ec in window_scroll
     (window=..., n=1, whole=true, noerror=false)
     at window.c:5471
#71 0x000055555565b461 in scroll_command
     (window=..., n=..., direction=1)
     at window.c:6177
#72 0x000055555565b5c8 in Fscroll_up (arg=...)
     at window.c:6204
#73 0x0000555555821569 in funcall_subr
     (subr=0x555555de1960 <Sscroll_up>, numargs=1, args=0x7fffffffc718) 
at eval.c:2868
#74 0x0000555555820fc9 in Ffuncall
     (nargs=2, args=0x7fffffffc710) at eval.c:2795
#75 0x000055555587d61a in exec_byte_code
     (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, 
args=0x7fffffffcd28)
     at bytecode.c:632
#76 0x0000555555821815 in fetch_and_exec_byte_code (fun=..., 
syms_left=..., nargs=1, args=0x7fffffffcd20) at eval.c:2917
#77 0x0000555555821cce in funcall_lambda
     (fun=..., nargs=1, arg_vector=0x7fffffffcd20)
     at eval.c:2998
#78 0x000055555582100d in Ffuncall
     (nargs=2, args=0x7fffffffcd18) at eval.c:2797
#79 0x0000555555814e31 in Ffuncall_interactively
     (nargs=2, args=0x7fffffffcd18)
     at callint.c:253
#80 0x000055555582143b in funcall_subr
     (subr=0x555555dec8e0 <Sfuncall_interactively>, numargs=2, 
args=0x7fffffffcd18) at eval.c:2848
#81 0x0000555555820fc9 in Ffuncall
     (nargs=3, args=0x7fffffffcd10) at eval.c:2795
#82 0x000055555581760c in Fcall_interactively
     (function=..., record_flag=..., keys=...)
     at callint.c:779
#83 0x00005555558215bc in funcall_subr
     (subr=0x555555dec920 <Scall_interactively>, numargs=3, 
args=0x7fffffffd0b0) at eval.c:2873
#84 0x0000555555820fc9 in Ffuncall
     (nargs=4, args=0x7fffffffd0a8) at eval.c:2795
#85 0x000055555587d61a in exec_byte_code
     (bytestr=..., vector=..., maxdepth=..., args_template=..., nargs=1, 
args=0x7fffffffd600)
     at bytecode.c:632
#86 0x0000555555821815 in fetch_and_exec_byte_code (fun=..., 
syms_left=..., nargs=1, args=0x7fffffff--Type <RET> for more, q to quit, 
c to continue without paging--
d5f8) at eval.c:2917
#87 0x0000555555821cce in funcall_lambda
     (fun=..., nargs=1, arg_vector=0x7fffffffd5f8)
     at eval.c:2998
#88 0x000055555582100d in Ffuncall
     (nargs=2, args=0x7fffffffd5f0) at eval.c:2797
#89 0x00005555558207d8 in call1
     (fn=..., arg1=...) at eval.c:2655
#90 0x000055555573b7f3 in command_loop_1 ()
     at keyboard.c:1463
#91 0x000055555581cc20 in internal_condition_case
     (bfun=0x55555573af39 <command_loop_1>, handlers=..., 
hfun=0x55555573a516 <cmd_error>)
     at eval.c:1356
#92 0x000055555573ab17 in command_loop_2
     (ignore=...) at keyboard.c:1091
#93 0x000055555581c045 in internal_catch
     (tag=..., func=0x55555573aaea <command_loop_2>, arg=...) at eval.c:1117
#94 0x000055555573aab6 in command_loop ()
     at keyboard.c:1070
#95 0x0000555555739ff9 in recursive_edit_1 ()
     at keyboard.c:714
#96 0x000055555573a1f5 in Frecursive_edit ()
     at keyboard.c:786
#97 0x0000555555735f3a in main
     (argc=1, argv=0x7fffffffdae8) at emacs.c:2047

The package for 'fontconfig' is

local/fontconfig 2:2.13.91+48+gfcb0420-2
     Library for configuring and customizing font access

For me, it's definitely a blocker for an upgrade to this new Emacs. 
Maybe the issue is with 'fontconfig', in any case, would be nice to 
understand what's happening here.  Please, advise.

Kind regards,
Alexander