Subject: bug#17125: 24.4.50; daemon mode: closing X client frame exits entire emacs

From: Dmitry Antipov <[email-masked]>
Date: Wed, 02 Apr 2014 16:24:05 +0400

On 04/02/2014 03:50 PM, Peder O. Klingenberg wrote:

> Success!
>
> Reverting bug17125_fixed.patch and applying your bug17125_fixed_2.patch,
> I have an emacs running in daemon mode which does not segfault anymore.
>
> Thanks!  This bug was really messing up my workflow.

This patch prevents [] (empty vector, means "no match") from entering font cache.
IMO this is correct, but this breaks current behavior of font_list_entities.
Could you please also try a more compatible/conservative change?

Dmitry

=== modified file 'src/font.c'
--- src/font.c	2014-03-03 19:58:20 +0000
+++ src/font.c	2014-04-02 12:12:21 +0000
@@ -2753,14 +2753,10 @@
 	  val = XCDR (val);
 	else
 	  {
-	    Lisp_Object copy;
+	    Lisp_Object copy = copy_font_spec (scratch_font_spec);
 
 	    val = driver_list->driver->list (f, scratch_font_spec);
-	    if (NILP (val))
-	      val = zero_vector;
-	    else
-	      val = Fvconcat (1, &val);
-	    copy = copy_font_spec (scratch_font_spec);
+	    val = NILP (val) ? zero_vector : Fvconcat (1, &val);
 	    ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type);
 	    XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache)));
 	  }
@@ -2804,7 +2800,6 @@
 	&& (NILP (ftype) || EQ (driver_list->driver->type, ftype)))
       {
 	Lisp_Object cache = font_get_cache (f, driver_list->driver);
-	Lisp_Object copy;
 
 	ASET (work, FONT_TYPE_INDEX, driver_list->driver->type);
 	entity = assoc_no_quit (work, XCDR (cache));
@@ -2812,10 +2807,12 @@
 	  entity = XCDR (entity);
 	else
 	  {
+	    Lisp_Object match, copy = copy_font_spec (work);
+
 	    entity = driver_list->driver->match (f, work);
-	    copy = copy_font_spec (work);
+	    match = NILP (entity) ? zero_vector : Fvector (1, &match);
 	    ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type);
-	    XSETCDR (cache, Fcons (Fcons (copy, entity), XCDR (cache)));
+	    XSETCDR (cache, Fcons (Fcons (copy, match), XCDR (cache)));
 	  }
 	if (! NILP (entity))
 	  break;