Subject: bug#20890: master 1233bcb: Work around GC+Cairo bug

From: Robert Pluim <[email-masked]>
Date: Wed, 04 Apr 2018 10:52:42 +0200

Eli Zaretskii <[email-masked]> writes:

>> From: Robert Pluim <[email-masked]>
>> Date: Wed, 04 Apr 2018 00:14:20 +0200
>> Cc: Paul Eggert <[email-masked]>
>> 
>> >     Work around GC+Cairo bug
>> >     
>> >     Workaround suggested by Robert Pluim (Bug#20890#13).
>> >     * src/ftfont.c (ftfont_close) [USE_CAIRO]:
>> >     Do nothing if GC is in progress.
>> 
>> And whilst this reduces the frequency of the issue, of course it
>> doesnʼt eliminate it. Currently Iʼve deployed the following
>> sledgehammer, but we really need something better:
>
> Sorry, I don't understand: are you saying that you still get crashes
> inside ftfont_close, after the above commit?  If so, can you please
> show the backtrace?

Yes.

> (Let's please continue discussing this in the bug report, not here.)

Moved there. Backtrace:

Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
0x00007ffff1f87c68 in FT_List_Find () from /usr/lib/x86_64-linux-gnu/libfreetype.so.6
(gdb) bt
#0  0x00007ffff1f87c68 in FT_List_Find () from /usr/lib/x86_64-linux-gnu/libfreetype.so.6
#1  0x00007ffff1f87ecf in FT_Done_Size () from /usr/lib/x86_64-linux-gnu/libfreetype.so.6
#2  0x00000000005d5484 in ftcrfont_close (font=0x35fdf60) at ftcrfont.c:176
#3  0x00000000005502db in cleanup_vector (vector=vector@entry=0x35fdf60) at alloc.c:3194
#4  0x000000000055134a in sweep_vectors () at alloc.c:3241
#5  0x00000000005556f7 in gc_sweep () at alloc.c:7191
#6  garbage_collect_1 (end=<optimized out>) at alloc.c:6030
#7  Fgarbage_collect () at alloc.c:6162
#8  0x000000000056df29 in maybe_gc () at lisp.h:4839
#9  Ffuncall (nargs=4, args=args@entry=0x7fffffff9a28) at eval.c:2803
#10 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x8dd84d), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9295952, args=<optimized out>, args@entry=0x7fffffff9a28)
    at bytecode.c:632
#11 0x000000000056ddd0 in funcall_lambda (fun=make_number(35184372082330), nargs=9295952, nargs@entry=5, 
    arg_vector=0x7fffffff9a28, arg_vector@entry=0x7fffffff9c18) at eval.c:3022
#12 0x000000000056e053 in Ffuncall (nargs=6, args=args@entry=0x7fffffff9c10) at eval.c:2835
#13 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x8dd8fd), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9296128, args=<optimized out>, args@entry=0x7fffffff9c10)
    at bytecode.c:632
#14 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffff9c64), nargs=9296128, nargs@entry=2, 
    arg_vector=0x7fffffff9c10, arg_vector@entry=0x7fffffff9df0) at eval.c:3022
#15 0x000000000056e053 in Ffuncall (nargs=3, args=args@entry=0x7fffffff9de8) at eval.c:2835
#16 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x8dd99d), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9296288, args=<optimized out>, args@entry=0x7fffffff9de8)
    at bytecode.c:632
#17 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffff9e27), nargs=9296288, nargs@entry=2, 
    arg_vector=0x7fffffff9de8, arg_vector@entry=0x7fffffff9fc0) at eval.c:3022
#18 0x000000000056e053 in Ffuncall (nargs=3, args=args@entry=0x7fffffff9fb8) at eval.c:2835
#19 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x8e163d), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9311808, args=<optimized out>, args@entry=0x7fffffff9fb8)
    at bytecode.c:632
#20 0x000000000056ddd0 in funcall_lambda (fun=make_number(35184372082708), nargs=9311808, nargs@entry=2, 
    arg_vector=0x7fffffff9fb8, arg_vector@entry=0x7fffffffa240) at eval.c:3022
#21 0x000000000056e053 in Ffuncall (nargs=3, args=args@entry=0x7fffffffa238) at eval.c:2835
#22 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x971615), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9901592, args=<optimized out>, args@entry=0x7fffffffa238)
    at bytecode.c:632
#23 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffa395), nargs=9901592, nargs@entry=1, 
    arg_vector=0x7fffffffa238, arg_vector@entry=0x7fffffffa4f8) at eval.c:3022
#24 0x000000000056e053 in Ffuncall (nargs=nargs@entry=2, args=args@entry=0x7fffffffa4f0) at eval.c:2835
#25 0x000000000056e1ba in call1 (fn=fn@entry=XIL(0x63c0), arg1=arg1@entry=XIL(0x3705335)) at eval.c:2672
#26 0x00000000004c08be in update_face_from_frame_parameter (f=f@entry=0x3705330, param=param@entry=XIL(0x2be0), 
    new_value=new_value@entry=XIL(0x35eabf4)) at xfaces.c:3256
#27 0x00000000004d959d in x_set_background_color (f=0x3705330, arg=XIL(0x35eabf4), oldval=<optimized out>)
    at xfns.c:1107
#28 0x000000000042bf18 in x_set_frame_parameters (f=f@entry=0x3705330, alist=alist@entry=XIL(0xc5b653))
    at frame.c:3919
#29 0x000000000042c77c in Fmodify_frame_parameters (frame=frame@entry=XIL(0x3705335), alist=XIL(0xc5b653))
    at frame.c:3183
#30 0x00000000004bc61f in Finternal_set_lisp_face_attribute (face=XIL(0x4770), attr=XIL(0x2a0), value=XIL(0x35eabf4), 
    frame=XIL(0x3705335)) at xfaces.c:3215
#31 0x000000000056e0f6 in Ffuncall (nargs=<optimized out>, args=args@entry=0x7fffffffa7e0) at eval.c:2821
#32 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x8de15d), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9298272, args=<optimized out>, args@entry=0x7fffffffa7e0)
    at bytecode.c:632
#33 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffa8d7), nargs=9298272, nargs@entry=32, 
    arg_vector=0x7fffffffa7e0, arg_vector@entry=0x7fffffffaa38) at eval.c:3022
#34 0x000000000056e053 in Ffuncall (nargs=nargs@entry=33, args=0x7fffffffaa30) at eval.c:2835
#35 0x000000000056fbc0 in Fapply (nargs=<optimized out>, args=0x7fffffffac40) at eval.c:2441
#36 0x000000000056e0f6 in Ffuncall (nargs=<optimized out>, args=args@entry=0x7fffffffac38) at eval.c:2821
#37 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x8e16fd), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9312000, args=<optimized out>, args@entry=0x7fffffffac38)
    at bytecode.c:632
#38 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffac88), nargs=9312000, nargs@entry=3, 
    arg_vector=0x7fffffffac38, arg_vector@entry=0x7fffffffae20) at eval.c:3022
#39 0x000000000056e053 in Ffuncall (nargs=4, args=args@entry=0x7fffffffae18) at eval.c:2835
#40 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x8e163d), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9311808, args=<optimized out>, args@entry=0x7fffffffae18)
    at bytecode.c:632
#41 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffae77), nargs=9311808, nargs@entry=2, 
    arg_vector=0x7fffffffae18, arg_vector@entry=0x7fffffffb030) at eval.c:3022
#42 0x000000000056e053 in Ffuncall (nargs=3, args=args@entry=0x7fffffffb028) at eval.c:2835
#43 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x8e27dd), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9316320, args=<optimized out>, args@entry=0x7fffffffb028)
    at bytecode.c:632
#44 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffb079), nargs=9316320, nargs@entry=2, 
    arg_vector=0x7fffffffb028, arg_vector@entry=0x7fffffffb240) at eval.c:3022
#45 0x000000000056e053 in Ffuncall (nargs=3, args=args@entry=0x7fffffffb238) at eval.c:2835
#46 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x8e25fd), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9315840, args=<optimized out>, args@entry=0x7fffffffb238)
    at bytecode.c:632
#47 0x000000000056ddd0 in funcall_lambda (fun=make_number(35184372083889), nargs=9315840, nargs@entry=1, 
    arg_vector=0x7fffffffb238, arg_vector@entry=0x7fffffffb448) at eval.c:3022
#48 0x000000000056e053 in Ffuncall (nargs=2, args=args@entry=0x7fffffffb440) at eval.c:2835
#49 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0xcbbb35), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=13351736, args=<optimized out>, args@entry=0x7fffffffb440)
    at bytecode.c:632
#50 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffb453), nargs=13351736, nargs@entry=1, 
    arg_vector=0x7fffffffb440, arg_vector@entry=0x7fffffffb688) at eval.c:3022
#51 0x000000000056e053 in Ffuncall (nargs=nargs@entry=2, args=args@entry=0x7fffffffb680) at eval.c:2835
#52 0x000000000056fda3 in Fapply (nargs=2, args=0x7fffffffb680) at eval.c:2398
#53 0x000000000056e0f6 in Ffuncall (nargs=<optimized out>, args=args@entry=0x7fffffffb678) at eval.c:2821
#54 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x12ca355), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=19702616, args=<optimized out>, args@entry=0x7fffffffb678)
    at bytecode.c:632
#55 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffb70d), nargs=19702616, nargs@entry=1, 
    arg_vector=0x7fffffffb678, arg_vector@entry=0x7fffffffb890) at eval.c:3022
#56 0x000000000056e053 in Ffuncall (nargs=2, args=args@entry=0x7fffffffb888) at eval.c:2835
#57 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x970995), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9898392, args=<optimized out>, args@entry=0x7fffffffb888)
    at bytecode.c:632
#58 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffb968), nargs=9898392, nargs@entry=1, 
    arg_vector=0x7fffffffb888, arg_vector@entry=0x7fffffffbb10) at eval.c:3022
#59 0x000000000056e053 in Ffuncall (nargs=2, args=args@entry=0x7fffffffbb08) at eval.c:2835
#60 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x9705b5), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9897400, args=<optimized out>, args@entry=0x7fffffffbb08)
    at bytecode.c:632
#61 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffbb27), nargs=9897400, nargs@entry=2, 
    arg_vector=0x7fffffffbb08, arg_vector@entry=0x7fffffffbcc8) at eval.c:3022
#62 0x000000000056e053 in Ffuncall (nargs=3, args=args@entry=0x7fffffffbcc0) at eval.c:2835
#63 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x19b10e5), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=26939624, args=<optimized out>, args@entry=0x7fffffffbcc0)
    at bytecode.c:632
#64 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffbdd3), nargs=26939624, nargs@entry=4, 
    arg_vector=0x7fffffffbcc0, arg_vector@entry=0x7fffffffc040) at eval.c:3022
#65 0x000000000056e053 in Ffuncall (nargs=5, args=args@entry=0x7fffffffc038) at eval.c:2835
#66 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x1a313b5), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=27464632, args=<optimized out>, args@entry=0x7fffffffc038)
    at bytecode.c:632
#67 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffc27d), nargs=27464632, nargs@entry=9, 
    arg_vector=0x7fffffffc038, arg_vector@entry=0x7fffffffc520) at eval.c:3022
#68 0x000000000056e053 in Ffuncall (nargs=10, args=args@entry=0x7fffffffc518) at eval.c:2835
#69 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x1e7dc45), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=31972424, args=<optimized out>, args@entry=0x7fffffffc518)
    at bytecode.c:632
#70 0x000000000056ddd0 in funcall_lambda (fun=make_number(35184372085087), nargs=31972424, nargs@entry=0, 
    arg_vector=0x7fffffffc518, arg_vector@entry=0x7fffffffc708) at eval.c:3022
#71 0x000000000056e053 in Ffuncall (nargs=1, args=args@entry=0x7fffffffc700) at eval.c:2835
#72 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x1eaa035), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=32153656, args=<optimized out>, args@entry=0x7fffffffc700)
    at bytecode.c:632
#73 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffc829), nargs=32153656, nargs@entry=0, 
    arg_vector=0x7fffffffc700, arg_vector@entry=0x7fffffffca10) at eval.c:3022
#74 0x000000000056e053 in Ffuncall (nargs=1, args=args@entry=0x7fffffffca08) at eval.c:2835
#75 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x1e7d235), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=31969848, args=<optimized out>, args@entry=0x7fffffffca08)
    at bytecode.c:632
#76 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffca3f), nargs=31969848, nargs@entry=0, 
    arg_vector=0x7fffffffca08, arg_vector@entry=0x7fffffffcbf8) at eval.c:3022
#77 0x000000000056e053 in Ffuncall (nargs=1, args=0x7fffffffcbf0) at eval.c:2835
#78 0x000000000056e119 in funcall_nil (nargs=<optimized out>, args=<optimized out>) at eval.c:2452
#79 0x000000000056cafd in run_hook_with_args (nargs=1, args=0x7fffffffcbf0, funcall=0x56e110 <funcall_nil>)
    at eval.c:2629
#80 0x000000000056cc46 in Frun_hook_with_args (args=0x7fffffffcbf0, nargs=1) at eval.c:2494
#81 run_hook (hook=XIL(0x1e7d285)) at eval.c:2642
#82 Frun_hooks (nargs=2, args=0x7fffffffcc70) at eval.c:2476
#83 0x000000000056e0f6 in Ffuncall (nargs=<optimized out>, args=args@entry=0x7fffffffcc68) at eval.c:2821
#84 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x978e85), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9932424, args=<optimized out>, args@entry=0x7fffffffcc68)
    at bytecode.c:632
#85 0x000000000056ddd0 in funcall_lambda (fun=make_number(35184372085891), nargs=9932424, nargs@entry=0, 
    arg_vector=0x7fffffffcc68, arg_vector@entry=0x7fffffffd468) at eval.c:3022
#86 0x000000000056e053 in Ffuncall (nargs=1, args=args@entry=0x7fffffffd460) at eval.c:2835
#87 0x00000000005a5f48 in exec_byte_code (bytestr=<optimized out>, vector=XIL(0x977e35), maxdepth=<optimized out>, 
    args_template=<optimized out>, nargs=nargs@entry=9928248, args=<optimized out>, args@entry=0x7fffffffd460)
    at bytecode.c:632
#88 0x000000000056ddd0 in funcall_lambda (fun=XIL(0x7fffffffd62c), fun@entry=XIL(0x977de5), nargs=9928248, 
    nargs@entry=0, arg_vector=0x7fffffffd460, arg_vector@entry=0x7fffffffd780) at eval.c:3022
#89 0x000000000056d0c0 in apply_lambda (fun=XIL(0x977de5), args=<optimized out>, count=count@entry=4) at eval.c:2958
#90 0x000000000056d472 in eval_sub (form=form@entry=XIL(0x1132f63)) at eval.c:2361
#91 0x00000000005715a8 in Feval (form=XIL(0x1132f63), lexical=<optimized out>) at eval.c:2106
#92 0x000000000056c67e in internal_condition_case (bfun=bfun@entry=0x4f7770 <top_level_2>, 
    handlers=handlers@entry=XIL(0x5250), hfun=hfun@entry=0x4fd000 <cmd_error>) at eval.c:1332
#93 0x00000000004fa02c in top_level_1 (ignore=ignore@entry=XIL(0)) at keyboard.c:1128
#94 0x000000000056c61c in internal_catch (tag=tag@entry=XIL(0xc960), func=func@entry=0x4f9fd0 <top_level_1>, 
    arg=arg@entry=XIL(0)) at eval.c:1097
#95 0x00000000004f7708 in command_loop () at keyboard.c:1089
#96 0x00000000004fcbe6 in recursive_edit_1 () at keyboard.c:696
#97 0x00000000004fcf30 in Frecursive_edit () at keyboard.c:767
#98 0x000000000041be36 in main (argc=1, argv=0x7fffffffdb48) at emacs.c:1724

Lisp Backtrace:
"Automatic GC" (0x0)
"internal-face-x-get-resource" (0xffff9a30)
"set-face-attribute-from-resource" (0xffff9c18)
"set-face-attributes-from-resources" (0xffff9df0)
"make-face-x-resource-internal" (0xffff9fc0)
"face-spec-recalc" (0xffffa240)
"frame-set-background-mode" (0xffffa4f8)
"internal-set-lisp-face-attribute" (0xffffa7e8)
"set-face-attribute" (0xffffaa38)
"apply" (0xffffac40)
"face-spec-set-2" (0xffffae20)
"face-spec-recalc" (0xffffb030)
"face-set-after-frame-default" (0xffffb240)
"x-create-frame-with-faces" (0xffffb448)
0x12cc430 PVEC_COMPILED
"apply" (0xffffb680)
"frame-creation-function" (0xffffb890)
"make-frame" (0xffffbb10)
"make-frame-on-display" (0xffffbcc8)
"frameset--restore-frame" (0xffffc040)
"frameset-restore" (0xffffc520)
"desktop-restore-frameset" (0xffffc708)
"desktop-read" (0xffffca10)
0x1e7d280 PVEC_COMPILED
"run-hooks" (0xffffcc70)
"command-line" (0xffffd468)
"normal-top-level" (0xffffd780)
(gdb)