[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 99e2ad9 2/2: Improve GC+Cairo workaround
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] emacs-26 99e2ad9 2/2: Improve GC+Cairo workaround |
Date: |
Sat, 5 Jan 2019 04:54:01 -0500 (EST) |
branch: emacs-26
commit 99e2ad9e4e5edeb91e739605c15dbf07f31143cc
Author: Paul Eggert <address@hidden>
Commit: Eli Zaretskii <address@hidden>
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.
(cherry picked from commit d02fd482fbeaf6ed551e78223b538495cb0c3541)
---
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 bb46833..b6e43b0 100644
--- a/src/font.h
+++ b/src/font.h
@@ -948,6 +948,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 0e3490c..62f4457 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -165,6 +165,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 bdb1dff..823fb20 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1243,15 +1243,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;