diff options
| author | Paul Eggert | 2018-04-04 10:59:09 -0700 |
|---|---|---|
| committer | Eli Zaretskii | 2019-01-05 11:53:04 +0200 |
| commit | 99e2ad9e4e5edeb91e739605c15dbf07f31143cc (patch) | |
| tree | e9d5314b6e0711fe1ae698c3eda5c90f71175e72 | |
| parent | e0862eda47c549850a43f09d12882849a2073f93 (diff) | |
| download | emacs-99e2ad9e4e5edeb91e739605c15dbf07f31143cc.tar.gz emacs-99e2ad9e4e5edeb91e739605c15dbf07f31143cc.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.
(cherry picked from commit d02fd482fbeaf6ed551e78223b538495cb0c3541)
| -rw-r--r-- | src/font.h | 16 | ||||
| -rw-r--r-- | src/ftcrfont.c | 3 | ||||
| -rw-r--r-- | src/ftfont.c | 9 |
3 files changed, 20 insertions, 8 deletions
diff --git a/src/font.h b/src/font.h index bb468333e85..b6e43b0c9ca 100644 --- a/src/font.h +++ b/src/font.h | |||
| @@ -948,6 +948,22 @@ extern void font_deferred_log (const char *, Lisp_Object, Lisp_Object); | |||
| 948 | font_deferred_log ((ACTION), (ARG), (RESULT)); \ | 948 | font_deferred_log ((ACTION), (ARG), (RESULT)); \ |
| 949 | } while (false) | 949 | } while (false) |
| 950 | 950 | ||
| 951 | /* FIXME: This is for use in functions that can be called while | ||
| 952 | garbage-collecting, but which assume that Lisp data structures are | ||
| 953 | properly-formed. This invalid assumption can lead to core dumps | ||
| 954 | (Bug#20890). */ | ||
| 955 | INLINE bool | ||
| 956 | font_data_structures_may_be_ill_formed (void) | ||
| 957 | { | ||
| 958 | #ifdef USE_CAIRO | ||
| 959 | /* Although this works around Bug#20890, it is probably not the | ||
| 960 | right thing to do. */ | ||
| 961 | return gc_in_progress; | ||
| 962 | #else | ||
| 963 | return false; | ||
| 964 | #endif | ||
| 965 | } | ||
| 966 | |||
| 951 | INLINE_HEADER_END | 967 | INLINE_HEADER_END |
| 952 | 968 | ||
| 953 | #endif /* not EMACS_FONT_H */ | 969 | #endif /* not EMACS_FONT_H */ |
diff --git a/src/ftcrfont.c b/src/ftcrfont.c index 0e3490c570e..62f44573a86 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c | |||
| @@ -165,6 +165,9 @@ ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 165 | static void | 165 | static void |
| 166 | ftcrfont_close (struct font *font) | 166 | ftcrfont_close (struct font *font) |
| 167 | { | 167 | { |
| 168 | if (font_data_structures_may_be_ill_formed ()) | ||
| 169 | return; | ||
| 170 | |||
| 168 | struct ftcrfont_info *ftcrfont_info = (struct ftcrfont_info *) font; | 171 | struct ftcrfont_info *ftcrfont_info = (struct ftcrfont_info *) font; |
| 169 | int i; | 172 | int i; |
| 170 | 173 | ||
diff --git a/src/ftfont.c b/src/ftfont.c index bdb1dff8cb9..823fb2095ce 100644 --- a/src/ftfont.c +++ b/src/ftfont.c | |||
| @@ -1243,15 +1243,8 @@ ftfont_open (struct frame *f, Lisp_Object entity, int pixel_size) | |||
| 1243 | void | 1243 | void |
| 1244 | ftfont_close (struct font *font) | 1244 | ftfont_close (struct font *font) |
| 1245 | { | 1245 | { |
| 1246 | /* FIXME: Although this function can be called while garbage-collecting, | 1246 | if (font_data_structures_may_be_ill_formed ()) |
| 1247 | the function assumes that Lisp data structures are properly-formed. | ||
| 1248 | This invalid assumption can lead to core dumps (Bug#20890). */ | ||
| 1249 | #ifdef USE_CAIRO | ||
| 1250 | /* Although this works around Bug#20890, it is probably not the | ||
| 1251 | right thing to do. */ | ||
| 1252 | if (gc_in_progress) | ||
| 1253 | return; | 1247 | return; |
| 1254 | #endif | ||
| 1255 | 1248 | ||
| 1256 | struct ftfont_info *ftfont_info = (struct ftfont_info *) font; | 1249 | struct ftfont_info *ftfont_info = (struct ftfont_info *) font; |
| 1257 | Lisp_Object val, cache; | 1250 | Lisp_Object val, cache; |