From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs Subject: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font) Date: Fri, 30 Oct 2015 12:17:36 -0700 Message-ID: <87io5ogo8f.fsf@secretsauce.net> References: <87zj082t34.fsf@gnu.org> <83io6wffm9.fsf@gnu.org> <87lhbqdhjp.fsf@secretsauce.net> <83d1x2eugp.fsf@gnu.org> <87oagl376v.fsf@secretsauce.net> <560BB690.3020804@yandex.ru> <87612q3oxj.fsf@secretsauce.net> <560D34CB.5010900@yandex.ru> <874mia2zjh.fsf@secretsauce.net> <560E106C.6010103@yandex.ru> <87r3kdguf9.fsf@secretsauce.net> <83wpu4zbe6.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1446232713 28808 80.91.229.3 (30 Oct 2015 19:18:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 Oct 2015 19:18:33 +0000 (UTC) Cc: dmantipov@yandex.ru, 21556@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 30 20:18:17 2015 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 1ZsFBo-0004la-RQ for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Oct 2015 20:18:17 +0100 Original-Received: from localhost ([::1]:52612 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsFBo-0005lb-3T for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Oct 2015 15:18:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55062) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsFBg-0005jG-ML for bug-gnu-emacs@gnu.org; Fri, 30 Oct 2015 15:18:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZsFBb-0006c3-25 for bug-gnu-emacs@gnu.org; Fri, 30 Oct 2015 15:18:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsFBa-0006bt-Ul for bug-gnu-emacs@gnu.org; Fri, 30 Oct 2015 15:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZsFBa-0000YZ-9L for bug-gnu-emacs@gnu.org; Fri, 30 Oct 2015 15:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Oct 2015 19:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21556 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21556-submit@debbugs.gnu.org id=B21556.14462326792126 (code B ref 21556); Fri, 30 Oct 2015 19:18:02 +0000 Original-Received: (at 21556) by debbugs.gnu.org; 30 Oct 2015 19:17:59 +0000 Original-Received: from localhost ([127.0.0.1]:46511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZsFBW-0000YC-RU for submit@debbugs.gnu.org; Fri, 30 Oct 2015 15:17:59 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:51013) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZsFBC-0000Xi-RA for 21556@debbugs.gnu.org; Fri, 30 Oct 2015 15:17:57 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id AE30720842 for <21556@debbugs.gnu.org>; Fri, 30 Oct 2015 15:17:38 -0400 (EDT) Original-Received: from frontend2 ([10.202.2.161]) by compute3.internal (MEProxy); Fri, 30 Oct 2015 15:17:38 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=RvRCn IiRz/yiWz3NfnSLPG7voYM=; b=CNO6levEv7XWsGPfREJK/q8YHV75GyXJfrj+w 523mc6KsMsrtWyhNTglrHMFJ8rMgezKLlXtHK8PPi8sH0lE3dVO6uWuTrZD9RIMO Y+1JZVQFYwQgYWlUwi6XECpMEPZUaQFQlU3GtuePa01Rq5Zx0+yjAkdWAi0zhRZ4 ym5Q4o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=RvRCnIiRz/yiWz3NfnSLPG7voYM=; b=gDonI ChTb6Y4GYtyWKWx+6HPnA4y1ExIpz8Zd4Bylb4LosLSsFAMAnv0xLr4JiKaq8AHM PKUkk5tFoK8Hxq2Sjpm9FbhxsPP2meWXHUGXPOW0KPENPKMwkPxMFwM7j95AvoCS HzYys8DOgrgXToBl4/LeWcvo7Y9C2aloLPxDdQ= X-Sasl-enc: H5cLtnJjZXQoPhpOUXMp7E0Ov/OXGpnU/yMxvljP7Xw9 1446232658 Original-Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com [50.1.153.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 2958A680152; Fri, 30 Oct 2015 15:17:38 -0400 (EDT) Original-Received: from ip6-localhost ([::1] helo=shorty) by shorty.local with esmtp (Exim 4.84) (envelope-from ) id 1ZsFBA-0004rG-Vl; Fri, 30 Oct 2015 12:17:37 -0700 In-reply-to: <83wpu4zbe6.fsf@gnu.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: 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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:108205 Archived-At: Eli Zaretskii writes: >> From: Dima Kogan >> Cc: Eli Zaretskii , handa@gnu.org, 21556@debbugs.gnu.org >> Date: Thu, 29 Oct 2015 15:51:38 -0700 >> >> Dmitry Antipov writes: >> >> > On 10/01/2015 09:50 PM, Dima Kogan wrote: >> > >> >> OK, so are you suggesting changing how mark_face_cache() works? How bad >> >> is it to accept that fonts and font entities are not necessarily linked, >> >> and to install the latest patch in this bug? >> > >> > I'm suggesting to check whether there are unmarked font objects after marking >> > from Vfontset_table, and, if so, understand whether it's correct. Otherwise >> > your patch, even being correct by itself, may just hide subtle GC bug. >> >> Hi. I looked at this again. Running the same test as before (emacs -Q, >> repeatedly creating/destroying client frame) I see: >> >> >> - entities are created with each new client frame but are /never/ >> marked. >> >> - entity-creation backtrace is always >> >> #0 0x000000000060e74e in font_make_entity () at font.c:173 >> #1 0x00000000006793ae in ftfont_pattern_entity (p=0xf8c180, extra=20784563) at ftfont.c:215 >> #2 0x000000000067b952 in ftfont_list (f=0x13fb8c0, spec=13463989) at ftfont.c:1057 >> #3 0x0000000000680de6 in xftfont_list (f=0x13fb8c0, spec=13463989) at xftfont.c:138 >> #4 0x0000000000615ebc in font_list_entities (f=0x13fb8c0, spec=20978277) at font.c:2780 >> #5 0x0000000000617c27 in font_find_for_lface (f=0x13fb8c0, attrs=0x7fff3ee81f50, spec=20082933, c=-1) at font.c:3262 >> #6 0x0000000000617fb0 in font_load_for_lface (f=0x13fb8c0, attrs=0x7fff3ee81f50, spec=20082933) at font.c:3335 >> #7 0x00000000006183a2 in font_open_by_spec (f=0x13fb8c0, spec=20082933) at font.c:3429 >> #8 0x0000000000618415 in font_open_by_name (f=0x13fb8c0, name=13702436) at font.c:3440 >> #9 0x000000000052fec4 in x_default_font_parameter (f=0x13fb8c0, parms=20784979) at xfns.c:2904 >> #10 0x0000000000530bc2 in Fx_create_frame (parms=20784979) at xfns.c:3139 >> >> - Vfontset_table has fontsets and font-specs in it, but NO >> font-entities. Marking from the Vfontset_table thus cannot mark any >> font entities. >> >> Where are the entities supposed to be referenced? Does it make sense >> they're never marked? > > It's a long time since we last spoke about this, so maybe I've lost > the focus. I'm forgetting what's happening here too, so trying to finish this bug now. > We are discussing a problem with leaking memory, right? If > font-entities are related to that, and if not marking them is the > cause of the memory leak, then you are, in effect, saying that when we > GC a font-entity, we should free some additional memory referenced by > that font-entity, is that correct? This isn't quite what's happening here. We have: - fonts (sometimes) live inside font-entities - before the patch in this report, the cache compaction code drops font entities that aren't marked from the cache - I'm observing that such unmarked entities sometimes contain marked fonts. These become un-cached when their entity is dropped - Fonts are eventually deallocated by traversing the cache, but these un-cached fonts are no longer in the cache, so they leak. So the entity isn't the thing that leaks, but fonts that were removed from the cache while still used. - Patch in report looks at the fonts in the entity, and drops the entity only if the contained fonts are unmarked also - Dmitry thinks that unmarked-fonts-inside-a-marked-entity is a situation that can't happen, so he requested a deeper look at this. In particular, he thinks that after marking from Vfontset_table, everything (fonts and entities) should be marked. My latest email was in reference to these questions. Hope this is useful