From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#20890: master 1233bcb: Work around GC+Cairo bug Date: Wed, 4 Apr 2018 11:00:55 -0700 Organization: UCLA Computer Science Department Message-ID: References: <20180403152442.25413.61540@vcs0.savannah.gnu.org> <20180403152443.B15F6215A9@vcs0.savannah.gnu.org> <87a7ukc4zn.fsf@gmail.com> <83k1tn4h4f.fsf@gnu.org> <878ta34alh.fsf@gmail.com> <837epn49v9.fsf@gnu.org> <87lge3w4t7.fsf@gmail.com> <831sfv3x3v.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------EAC17C48F9DCCC2E47A0AAB6" X-Trace: blaine.gmane.org 1522864815 6449 195.159.176.226 (4 Apr 2018 18:00:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 4 Apr 2018 18:00:15 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 Cc: 20890@debbugs.gnu.org To: Eli Zaretskii , Robert Pluim Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 04 20:00:10 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f3mhd-0001XW-F8 for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Apr 2018 20:00:09 +0200 Original-Received: from localhost ([::1]:47441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3mjh-0006nX-4M for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Apr 2018 14:02:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3mjW-0006nB-9o for bug-gnu-emacs@gnu.org; Wed, 04 Apr 2018 14:02:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3mjT-0005ur-43 for bug-gnu-emacs@gnu.org; Wed, 04 Apr 2018 14:02:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58922) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f3mjT-0005uk-0C for bug-gnu-emacs@gnu.org; Wed, 04 Apr 2018 14:02:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f3mjS-0007VQ-FK for bug-gnu-emacs@gnu.org; Wed, 04 Apr 2018 14:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Apr 2018 18:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20890 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 20890-submit@debbugs.gnu.org id=B20890.152286486728792 (code B ref 20890); Wed, 04 Apr 2018 18:02:02 +0000 Original-Received: (at 20890) by debbugs.gnu.org; 4 Apr 2018 18:01:07 +0000 Original-Received: from localhost ([127.0.0.1]:38586 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f3miY-0007UJ-PQ for submit@debbugs.gnu.org; Wed, 04 Apr 2018 14:01:07 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:32862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f3miW-0007Th-9Z for 20890@debbugs.gnu.org; Wed, 04 Apr 2018 14:01:04 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 070AD16162D; Wed, 4 Apr 2018 11:00:58 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id VXBuDNCqz90V; Wed, 4 Apr 2018 11:00:55 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 8E2EF161631; Wed, 4 Apr 2018 11:00:55 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qClr5pje7lJ5; Wed, 4 Apr 2018 11:00:55 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 6C29116161F; Wed, 4 Apr 2018 11:00:55 -0700 (PDT) In-Reply-To: <831sfv3x3v.fsf@gnu.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:144893 Archived-At: This is a multi-part message in MIME format. --------------EAC17C48F9DCCC2E47A0AAB6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 04/04/2018 06:44 AM, Eli Zaretskii wrote: > Then I think we should install it. OK, I installed the attached into master. --------------EAC17C48F9DCCC2E47A0AAB6 Content-Type: text/x-patch; name="0001-Improve-GC-Cairo-workaround.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Improve-GC-Cairo-workaround.patch" >From 81f2010c21849e758a53f1d0c58c465146c1efee Mon Sep 17 00:00:00 2001 From: Paul Eggert 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 --------------EAC17C48F9DCCC2E47A0AAB6--