Subject: bug#30788: 27.0.50; Getting 'char-displayable-p: Invalid hash table rehash size: 1.0' when starting emacs -Q

From: Eli Zaretskii <[email-masked]>
Date: Wed, 14 Mar 2018 18:15:20 +0200

> Date: Wed, 14 Mar 2018 07:48:51 +0100
> Cc: [email-masked],
>     [email-masked]
> From: Ulrich Mueller <[email-masked]>
> 
> >>>>> On Wed, 14 Mar 2018, Eli Zaretskii wrote:
> 
> > OK, thanks.  Can you tell when this code is called from Emacs?
> > I don't see any direct calls to FcConfigEnsure in the sources.
> 
> (gdb) bt
> #0  FcConfigEnsure ()
>     at /var/tmp/portage/media-libs/fontconfig-2.13.0/work/fontconfig-2.13.0/src/fccfg.c:40
> #1  0x00007fffeeb2a849 in FcConfigInit ()
>     at /var/tmp/portage/media-libs/fontconfig-2.13.0/work/fontconfig-2.13.0/src/fccfg.c:71
> #2  0x00007fffeeb37c95 in IA__FcInit ()
>     at /var/tmp/portage/media-libs/fontconfig-2.13.0/work/fontconfig-2.13.0/src/fcinit.c:192
> #3  0x00007ffff44854b3 in XftInit (config=config@entry=0x0)
>     at /var/tmp/portage/x11-libs/libXft-2.3.2/work/libXft-2.3.2/src/xftinit.c:33
> #4  0x00000000004ea92b in xg_initialize () at gtkutil.c:5272
> #5  0x00000000004d0a13 in x_term_init (
>     display_name=display_name@entry=0x2c61b24, 
>     xrm_option=xrm_option@entry=0x0, resource_name=0x2c676a8 "emacs-27-vcs")
>     at xterm.c:12429

Thanks.  So the patch below should fix the problem, I think.  Can you
test it?

diff --git a/src/xterm.c b/src/xterm.c
index c5163aa..7b445e5 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -12411,12 +12411,16 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
         unrequest_sigio (); /* See comment in x_display_ok.  */
         gtk_init (&argc, &argv2);
         request_sigio ();
-        fixup_locale ();
 
         g_log_remove_handler ("GLib", id);
 
         xg_initialize ();
 
+	/* Do this after the call to xg_initialize, because when
+	   Fontconfig is used, xg_initialize calls its initialization
+	   function which in some versions of Fontconfig calls setlocale.  */
+	fixup_locale ();
+
         dpy = DEFAULT_GDK_DISPLAY ();
 
 #if ! GTK_CHECK_VERSION (2, 90, 0)