Subject: Re: bug#23386: Segfault when messing with font-backend

From: Eli Zaretskii <[email-masked]>
Date: Mon, 11 Jul 2016 17:33:29 +0300

> From: [email-masked]
> Date: Sun, 10 Jul 2016 16:17:00 -0400
> Cc: Stefan Monnier <[email-masked]>, [email-masked]
> 
> Dmitry Antipov <[email-masked]> writes:
> 
> > IMHO the original trick (request to drop font backend when there is a font
> > opened by using this backend) is practically meaningless, so why just not
> > prohibit it explicitly? For example, with:
> 
> Maybe that is a better idea; it does prevent the segfault, and it's
> certainly simpler.

But it doesn't do what the user asked for.

I don't see why it would be meaningless to evict a backend and start
using another one, if all it takes is re-open a bunch of fonts.

So I'm in favor of Noam's proposal, assuming that it works.

Noam, I encourage you to dig some more into this "forest", until you
convince yourself that the patch is sound.  While at that, please
consider adding comments where you learn useful things that are not
trivial to understand from the code alone, as this area of Emacs
sources is notoriously under-documented.

One issue that bothers me is this: what if additional fonts were
already opened for non-default faces?  Should they also get some
treatment?  (This is relevant to Dmitry's suggestion as well.)

I have one comment about your patch:

> diff --git a/src/xfns.c b/src/xfns.c
> index 7c1bb1c..1b9dd48 100644
> --- a/src/xfns.c
> +++ b/src/xfns.c
> @@ -3071,7 +3071,7 @@ do_unwind_create_frame (Lisp_Object frame)
>    unwind_create_frame (frame);
>  }
>  
> -static void
> +void
>  x_default_font_parameter (struct frame *f, Lisp_Object parms)
>  {
>    struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);

This cannot be done only in xfns.c, as it will then break the other
platforms, because x_set_font_backend is not specific to X.

Thanks.