emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r115541: * font.c (valid_font_driver) [ENABLE_CHECKI


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r115541: * font.c (valid_font_driver) [ENABLE_CHECKING]: New function
Date: Mon, 16 Dec 2013 07:47:48 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 115541
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Mon 2013-12-16 11:45:33 +0400
message:
  * font.c (valid_font_driver) [ENABLE_CHECKING]: New function
  intended to find bogus pointers in font objects (Bug#16140).
  * font.h (valid_font_driver) [ENABLE_CHECKING]: Add prototype.
  * alloc.c (cleanup_vector): Use valid_font_driver in eassert.
  (compact_font_cache_entry, compact_font_caches) [!HAVE_NTGUI]:
  Disable for MS-Windows due to Bug#15876; apparently this
  requires more or less substantial changes in fontset code.
  * xfont.c (xfont_close):
  * xftfont.c (xftfont_close): Call x_display_info_for_display
  to check whether 'Display *' is valid (Bug#16093 and probably
  Bug#16069).
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/alloc.c                    alloc.c-20091113204419-o5vbwnq5f7feedwu-252
  src/font.c                     font.c-20091113204419-o5vbwnq5f7feedwu-8540
  src/font.h                     font.h-20091113204419-o5vbwnq5f7feedwu-8541
  src/xfont.c                    xfont.c-20091113204419-o5vbwnq5f7feedwu-8547
  src/xftfont.c                  xftfont.c-20091113204419-o5vbwnq5f7feedwu-8548
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-12-15 20:39:36 +0000
+++ b/src/ChangeLog     2013-12-16 07:45:33 +0000
@@ -1,3 +1,17 @@
+2013-12-16  Dmitry Antipov  <address@hidden>
+
+       * font.c (valid_font_driver) [ENABLE_CHECKING]: New function
+       intended to find bogus pointers in font objects (Bug#16140).
+       * font.h (valid_font_driver) [ENABLE_CHECKING]: Add prototype.
+       * alloc.c (cleanup_vector): Use valid_font_driver in eassert.
+       (compact_font_cache_entry, compact_font_caches) [!HAVE_NTGUI]:
+       Disable for MS-Windows due to Bug#15876; apparently this
+       requires more or less substantial changes in fontset code.
+       * xfont.c (xfont_close):
+       * xftfont.c (xftfont_close): Call x_display_info_for_display
+       to check whether 'Display *' is valid (Bug#16093 and probably
+       Bug#16069).
+
 2013-12-15  Eli Zaretskii  <address@hidden>
 
        * fileio.c (Fexpand_file_name) [WINDOWSNT]: Fix conditionals.

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2013-12-14 09:57:53 +0000
+++ b/src/alloc.c       2013-12-16 07:45:33 +0000
@@ -2877,7 +2877,11 @@
   if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_FONT)
       && ((vector->header.size & PSEUDOVECTOR_SIZE_MASK)
          == FONT_OBJECT_MAX))
-    ((struct font *) vector)->driver->close ((struct font *) vector);
+    {
+      /* Attempt to catch subtle bugs like Bug#16140.  */
+      eassert (valid_font_driver (((struct font *) vector)->driver));
+      ((struct font *) vector)->driver->close ((struct font *) vector);
+    }
 }
 
 /* Reclaim space used by unmarked vectors.  */
@@ -5299,6 +5303,10 @@
 
 #ifdef HAVE_WINDOW_SYSTEM
 
+/* This code has a few issues on MS-Windows, see Bug#15876 and Bug#16140.  */
+
+#if !defined (HAVE_NTGUI)
+
 /* Remove unmarked font-spec and font-entity objects from ENTRY, which is
    (DRIVER-TYPE NUM-FRAMES FONT-CACHE-DATA ...), and return changed entry.  */
 
@@ -5337,6 +5345,8 @@
   return entry;
 }
 
+#endif /* not HAVE_NTGUI */
+
 /* Compact font caches on all terminals and mark
    everything which is still here after compaction.  */
 
@@ -5348,7 +5358,7 @@
   for (t = terminal_list; t; t = t->next_terminal)
     {
       Lisp_Object cache = TERMINAL_FONT_CACHE (t);
-
+#if !defined (HAVE_NTGUI)
       if (CONSP (cache))
        {
          Lisp_Object entry;
@@ -5356,6 +5366,7 @@
          for (entry = XCDR (cache); CONSP (entry); entry = XCDR (entry))
            XSETCAR (entry, compact_font_cache_entry (XCAR (entry)));
        }
+#endif /* not HAVE_NTGUI */
       mark_object (cache);
     }
 }

=== modified file 'src/font.c'
--- a/src/font.c        2013-12-13 15:55:23 +0000
+++ b/src/font.c        2013-12-16 07:45:33 +0000
@@ -148,7 +148,27 @@
    here.  */
 static struct font_driver_list *font_driver_list;
 
-
+#ifdef ENABLE_CHECKING
+
+/* Used to catch bogus pointers in font objects.  */
+
+bool
+valid_font_driver (struct font_driver *drv)
+{
+  Lisp_Object tail, frame;
+  struct font_driver_list *fdl;
+
+  for (fdl = font_driver_list; fdl; fdl = fdl->next)
+    if (fdl->driver == drv)
+      return true;
+  FOR_EACH_FRAME (tail, frame)
+    for (fdl = XFRAME (frame)->font_driver_list; fdl; fdl = fdl->next)
+      if (fdl->driver == drv)
+       return true;
+  return false;
+}
+
+#endif /* ENABLE_CHECKING */
 
 /* Creators of font-related Lisp object.  */
 

=== modified file 'src/font.h'
--- a/src/font.h        2013-12-14 21:36:44 +0000
+++ b/src/font.h        2013-12-16 07:45:33 +0000
@@ -787,6 +787,9 @@
                                 char *name, int bytes);
 extern void register_font_driver (struct font_driver *driver, struct frame *f);
 extern void free_font_driver_list (struct frame *f);
+#ifdef ENABLE_CHECKING
+extern bool valid_font_driver (struct font_driver *);
+#endif
 extern Lisp_Object font_update_drivers (struct frame *f, Lisp_Object list);
 extern Lisp_Object font_range (ptrdiff_t, ptrdiff_t, ptrdiff_t *,
                               struct window *, struct face *,

=== modified file 'src/xfont.c'
--- a/src/xfont.c       2013-12-13 15:55:23 +0000
+++ b/src/xfont.c       2013-12-16 07:45:33 +0000
@@ -894,7 +894,10 @@
 {
   struct xfont_info *xfi = (struct xfont_info *) font;
 
-  if (xfi->xfont)
+  /* This function may be called from GC when X connection is gone
+     (Bug#16093), and an attempt to free font resourses on invalid
+     display may lead to X protocol errors or segfaults.  */
+  if (xfi->xfont && x_display_info_for_display (xfi->display))
     {
       block_input ();
       XFreeFont (xfi->display, xfi->xfont);

=== modified file 'src/xftfont.c'
--- a/src/xftfont.c     2013-12-13 15:55:23 +0000
+++ b/src/xftfont.c     2013-12-16 07:45:33 +0000
@@ -491,7 +491,9 @@
     }
 #endif
 
-  if (xftfont_info->xftfont)
+  /* See comment in xfont_close.  */
+  if (xftfont_info->xftfont
+      && x_display_info_for_display (xftfont_info->display))
     {
       block_input ();
       XftUnlockFace (xftfont_info->xftfont);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]