all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>, Robert Pluim <rpluim@gmail.com>
Cc: 20890@debbugs.gnu.org
Subject: bug#20890: master 1233bcb: Work around GC+Cairo bug
Date: Wed, 4 Apr 2018 11:00:55 -0700	[thread overview]
Message-ID: <dcfc8d4a-324d-7942-e495-6078bb372a74@cs.ucla.edu> (raw)
In-Reply-To: <831sfv3x3v.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 126 bytes --]

On 04/04/2018 06:44 AM, Eli Zaretskii wrote:
> Then I think we should install it.

OK, I installed the attached into master.


[-- Attachment #2: 0001-Improve-GC-Cairo-workaround.patch --]
[-- Type: text/x-patch, Size: 2518 bytes --]

From 81f2010c21849e758a53f1d0c58c465146c1efee Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 4 Apr 2018 10:59:09 -0700
Subject: [PATCH] Improve GC+Cairo workaround

Suggested by Eli Zaretskii (Bug#20890#31).
* src/font.h (font_data_structures_may_be_ill_formed): New function.
* src/ftfont.c (ftfont_close):
* src/ftcrfont.c (ftcrfont_close): Use it.
---
 src/font.h     | 16 ++++++++++++++++
 src/ftcrfont.c |  3 +++
 src/ftfont.c   |  9 +--------
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/font.h b/src/font.h
index d88c8eb4f6..469431fee6 100644
--- a/src/font.h
+++ b/src/font.h
@@ -945,6 +945,22 @@ extern void font_deferred_log (const char *, Lisp_Object, Lisp_Object);
       font_deferred_log ((ACTION), (ARG), (RESULT));	\
   } while (false)
 
+/* FIXME: This is for use in functions that can be called while
+   garbage-collecting, but which assume that Lisp data structures are
+   properly-formed.  This invalid assumption can lead to core dumps
+   (Bug#20890).  */
+INLINE bool
+font_data_structures_may_be_ill_formed (void)
+{
+#ifdef USE_CAIRO
+  /* Although this works around Bug#20890, it is probably not the
+     right thing to do.  */
+  return gc_in_progress;
+#else
+  return false;
+#endif
+}
+
 INLINE_HEADER_END
 
 #endif	/* not EMACS_FONT_H */
diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index 614ef08370..425250e229 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -164,6 +164,9 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
 static void
 ftcrfont_close (struct font *font)
 {
+  if (font_data_structures_may_be_ill_formed ())
+    return;
+
   struct ftcrfont_info *ftcrfont_info = (struct ftcrfont_info *) font;
   int i;
 
diff --git a/src/ftfont.c b/src/ftfont.c
index 51b04a8682..9a8777ef07 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1242,15 +1242,8 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
 void
 ftfont_close (struct font *font)
 {
-  /* FIXME: Although this function can be called while garbage-collecting,
-     the function assumes that Lisp data structures are properly-formed.
-     This invalid assumption can lead to core dumps (Bug#20890).  */
-#ifdef USE_CAIRO
-  /* Although this works around Bug#20890, it is probably not the
-     right thing to do.  */
-  if (gc_in_progress)
+  if (font_data_structures_may_be_ill_formed ())
     return;
-#endif
 
   struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
   Lisp_Object val, cache;
-- 
2.14.3


      reply	other threads:[~2018-04-04 18:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180403152442.25413.61540@vcs0.savannah.gnu.org>
     [not found] ` <20180403152443.B15F6215A9@vcs0.savannah.gnu.org>
2018-04-03 22:14   ` master 1233bcb: Work around GC+Cairo bug Robert Pluim
2018-04-04  6:31     ` Eli Zaretskii
2015-06-24 10:26       ` bug#20890: 25.0.50; build from git crashes on startup Robert Marshall
2015-07-26 20:30         ` Paul Eggert
2018-04-03  9:39           ` Robert Pluim
2018-04-03 10:06             ` Eli Zaretskii
2018-04-03 15:03               ` Paul Eggert
2018-04-03 15:13                 ` Eli Zaretskii
2018-04-03 15:26                   ` Paul Eggert
2018-04-04  8:52         ` bug#20890: master 1233bcb: Work around GC+Cairo bug Robert Pluim
2018-04-04  9:08           ` Eli Zaretskii
2018-04-04 12:10         ` Robert Pluim
2018-04-04 13:44           ` Eli Zaretskii
2018-04-04 18:00             ` Paul Eggert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dcfc8d4a-324d-7942-e495-6078bb372a74@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=20890@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=rpluim@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.