From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Antipov Newsgroups: gmane.emacs.bugs Subject: bug#18501: Acknowledgement (24.3.93; OS X; crash in free() when calling macfont_close()) Date: Sat, 20 Sep 2014 05:08:15 +0400 Message-ID: <541CD37F.3030802@yandex.ru> References: <20140917233849.GA25143@home.blackbean.org> <20140919180528.GA8843@home.blackbean.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000205020908000502050903" X-Trace: ger.gmane.org 1411175373 720 80.91.229.3 (20 Sep 2014 01:09:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Sep 2014 01:09:33 +0000 (UTC) Cc: 18501@debbugs.gnu.org To: Jim Radford Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 20 03:09:26 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XV9Az-0007kU-RI for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Sep 2014 03:09:26 +0200 Original-Received: from localhost ([::1]:32970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XV9Az-00038y-A1 for geb-bug-gnu-emacs@m.gmane.org; Fri, 19 Sep 2014 21:09:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XV9Ap-00038s-MN for bug-gnu-emacs@gnu.org; Fri, 19 Sep 2014 21:09:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XV9Ai-0007rw-Gd for bug-gnu-emacs@gnu.org; Fri, 19 Sep 2014 21:09:15 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54614) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XV9Ai-0007qm-A5 for bug-gnu-emacs@gnu.org; Fri, 19 Sep 2014 21:09:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XV9Ac-0007Uo-I5 for bug-gnu-emacs@gnu.org; Fri, 19 Sep 2014 21:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Antipov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Sep 2014 01:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18501 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18501-submit@debbugs.gnu.org id=B18501.141117530428766 (code B ref 18501); Sat, 20 Sep 2014 01:09:02 +0000 Original-Received: (at 18501) by debbugs.gnu.org; 20 Sep 2014 01:08:24 +0000 Original-Received: from localhost ([127.0.0.1]:46178 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XV99z-0007Tu-RW for submit@debbugs.gnu.org; Fri, 19 Sep 2014 21:08:24 -0400 Original-Received: from forward4p.cmail.yandex.net ([77.88.31.19]:59497) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XV99x-0007Tk-AP for 18501@debbugs.gnu.org; Fri, 19 Sep 2014 21:08:22 -0400 Original-Received: from smtp17.mail.yandex.net (smtp17.mail.yandex.net [95.108.252.17]) by forward4p.cmail.yandex.net (Yandex) with ESMTP id A431C11B0; Sat, 20 Sep 2014 05:08:16 +0400 (MSK) Original-Received: from smtp17.mail.yandex.net (localhost [127.0.0.1]) by smtp17.mail.yandex.net (Yandex) with ESMTP id 64DF119015A0; Sat, 20 Sep 2014 05:08:16 +0400 (MSK) Original-Received: from unknown (unknown [37.139.80.10]) by smtp17.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id AyQy033TWK-8FVqGkNI; Sat, 20 Sep 2014 05:08:15 +0400 (using TLSv1.2 with cipher AES128-SHA (128/128 bits)) (Client certificate not present) X-Yandex-Uniq: ba213810-10de-4175-9ada-14cd58979941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1411175295; bh=ZB77lSKmjh93KEAzQPp8dRDWtvmKvNmJQCd7SKlr9jo=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type; b=o/INgRiaNPOJdiSpJ1I9SwSEcPQC+8Co4qgxjoC+TRR2bk78vWf9cZoTM8fIjMjEd bLiWcyulFNHp7gJwuslcSnnlPhKF9/DN9MWSP3buM0wivGDSlR2p1MyXIQfbB+Gj6V 4kC19UZ68OKCuzFa3cLrz/DxNGITERGiSjaA6wK0= Authentication-Results: smtp17.mail.yandex.net; dkim=pass header.i=@yandex.ru User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 In-Reply-To: <20140919180528.GA8843@home.blackbean.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:93540 Archived-At: This is a multi-part message in MIME format. --------------000205020908000502050903 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 09/19/2014 10:05 PM, Jim Radford wrote: > Here are the two calls that free the font: > > frame #1: 0x00000001001c5ffd Emacs`macfont_close(font=0x0000000105c2a8c0) + 13 at macfont.m:2621 > frame #2: 0x000000010014de80 Emacs`font_clear_cache(f=, cache=, driver=) + 304 at font.c:2620 > > frame #1: 0x00000001001c5ffd Emacs`macfont_close(font=0x0000000105c2a8c0) + 13 at macfont.m:2621 > frame #2: 0x000000010011be9d Emacs`Fgarbage_collect [inlined] cleanup_vector + 38 at alloc.c:2935 > > Notice that the pointer is the same in both cases. Both cleanup_vector() and font_clear_cache() call > > drv->close(font) > > It seems that font_clear_cache is leaving the font around for the GC to clean up (a second time) later. Please try this. Dmitry --------------000205020908000502050903 Content-Type: text/x-diff; name="bug18501.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="bug18501.patch" === modified file 'src/macfont.m' --- src/macfont.m 2014-07-20 13:18:47 +0000 +++ src/macfont.m 2014-09-20 01:05:58 +0000 @@ -2616,20 +2616,25 @@ macfont_close (struct font *font) { struct macfont_info *macfont_info = (struct macfont_info *) font; - int i; - - block_input (); - CFRelease (macfont_info->macfont); - CGFontRelease (macfont_info->cgfont); - if (macfont_info->screen_font) - CFRelease (macfont_info->screen_font); - macfont_release_cache (macfont_info->cache); - for (i = 0; i < macfont_info->metrics_nrows; i++) - if (macfont_info->metrics[i]) - xfree (macfont_info->metrics[i]); - if (macfont_info->metrics) - xfree (macfont_info->metrics); - unblock_input (); + + if (macfont_info->cache) + { + int i; + + block_input (); + CFRelease (macfont_info->macfont); + CGFontRelease (macfont_info->cgfont); + if (macfont_info->screen_font) + CFRelease (macfont_info->screen_font); + macfont_release_cache (macfont_info->cache); + for (i = 0; i < macfont_info->metrics_nrows; i++) + if (macfont_info->metrics[i]) + xfree (macfont_info->metrics[i]); + if (macfont_info->metrics) + xfree (macfont_info->metrics); + macfont_info->cache = NULL; + unblock_input (); + } } static int --------------000205020908000502050903--