aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2018-04-04 10:59:09 -0700
committerPaul Eggert2018-04-04 10:59:53 -0700
commitd02fd482fbeaf6ed551e78223b538495cb0c3541 (patch)
tree3e4f5f3b468b8208808c2ac2bc068fbae56ff235 /src
parent2f779d8ce804de84fed55a6b0aa74499ef369852 (diff)
downloademacs-d02fd482fbeaf6ed551e78223b538495cb0c3541.tar.gz
emacs-d02fd482fbeaf6ed551e78223b538495cb0c3541.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/font.h16
-rw-r--r--src/ftcrfont.c3
-rw-r--r--src/ftfont.c9
3 files changed, 20 insertions, 8 deletions
diff --git a/src/font.h b/src/font.h
index d88c8eb4f66..469431fee67 100644
--- a/src/font.h
+++ b/src/font.h
@@ -945,6 +945,22 @@ extern void font_deferred_log (const char *, Lisp_Object, Lisp_Object);
945 font_deferred_log ((ACTION), (ARG), (RESULT)); \ 945 font_deferred_log ((ACTION), (ARG), (RESULT)); \
946 } while (false) 946 } while (false)
947 947
948/* FIXME: This is for use in functions that can be called while
949 garbage-collecting, but which assume that Lisp data structures are
950 properly-formed. This invalid assumption can lead to core dumps
951 (Bug#20890). */
952INLINE bool
953font_data_structures_may_be_ill_formed (void)
954{
955#ifdef USE_CAIRO
956 /* Although this works around Bug#20890, it is probably not the
957 right thing to do. */
958 return gc_in_progress;
959#else
960 return false;
961#endif
962}
963
948INLINE_HEADER_END 964INLINE_HEADER_END
949 965
950#endif /* not EMACS_FONT_H */ 966#endif /* not EMACS_FONT_H */
diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index 614ef083701..425250e2297 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -164,6 +164,9 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
164static void 164static void
165ftcrfont_close (struct font *font) 165ftcrfont_close (struct font *font)
166{ 166{
167 if (font_data_structures_may_be_ill_formed ())
168 return;
169
167 struct ftcrfont_info *ftcrfont_info = (struct ftcrfont_info *) font; 170 struct ftcrfont_info *ftcrfont_info = (struct ftcrfont_info *) font;
168 int i; 171 int i;
169 172
diff --git a/src/ftfont.c b/src/ftfont.c
index 51b04a86829..9a8777ef078 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1242,15 +1242,8 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
1242void 1242void
1243ftfont_close (struct font *font) 1243ftfont_close (struct font *font)
1244{ 1244{
1245 /* FIXME: Although this function can be called while garbage-collecting, 1245 if (font_data_structures_may_be_ill_formed ())
1246 the function assumes that Lisp data structures are properly-formed.
1247 This invalid assumption can lead to core dumps (Bug#20890). */
1248#ifdef USE_CAIRO
1249 /* Although this works around Bug#20890, it is probably not the
1250 right thing to do. */
1251 if (gc_in_progress)
1252 return; 1246 return;
1253#endif
1254 1247
1255 struct ftfont_info *ftfont_info = (struct ftfont_info *) font; 1248 struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
1256 Lisp_Object val, cache; 1249 Lisp_Object val, cache;