GNU bug report logs - #21556
25.0.50; Memory leak in emacs -Q with lucid (font cache cleared prematurely)

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Dima Kogan <dima@HIDDEN>; dated Fri, 25 Sep 2015 00:06:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 29 Oct 2015 22:51:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 29 18:51:44 2015
Received: from localhost ([127.0.0.1]:44853 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Zrw2q-000639-9b
	for submit <at> debbugs.gnu.org; Thu, 29 Oct 2015 18:51:44 -0400
Received: from out4-smtp.messagingengine.com ([66.111.4.28]:59821)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dima@HIDDEN>) id 1Zrw2o-00062w-KS
 for 21556 <at> debbugs.gnu.org; Thu, 29 Oct 2015 18:51:43 -0400
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
 by mailout.nyi.internal (Postfix) with ESMTP id 7B7BD20AA7
 for <21556 <at> debbugs.gnu.org>; Thu, 29 Oct 2015 18:51:40 -0400 (EDT)
Received: from frontend2 ([10.202.2.161])
 by compute1.internal (MEProxy); Thu, 29 Oct 2015 18:51:40 -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=bIgTJ
 4Lz8ObJaFA9iYSS+1Q24YM=; b=BPVXqwZi4OSBq/qjH5cY5BcRyonhuPrXR5mby
 csGWown48tVfTKK/XVgXN/S07P6rwuklDNpLOdel9690t2xGueDZINOooQRgeISf
 H11lOaS19AExiWPCJhSbt/rqk2ixlp0LwAo+DS+PJUeYiSkXqWerQKJJn/SMFGZo
 jzJBQ0=
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=bIgTJ4Lz8ObJaFA9iYSS+1Q24YM=; b=qagx4
 xunL1EnRc4ANljT6kr6NDpAV904jhw3Qpqb0JS/bAa6LSJfrudk2GSFAo5oBgP8s
 ghTj80RlWygZFG/abKeZKXxpimFGad/X88ZI+tk0vgOEsRZWpXBUchbhRN2eiLx7
 yDRdH7xIFTAvQILQqNvBYvTpjVO30tcxeZnaF8=
X-Sasl-enc: Yyml5GWRD+R9MU9lJIC+Cm1Q4bp9PHLoq9EXF2y4d+68 1446159100
Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com
 [50.1.153.216])
 by mail.messagingengine.com (Postfix) with ESMTPA id 007C1680118;
 Thu, 29 Oct 2015 18:51:39 -0400 (EDT)
Received: from ip6-localhost ([::1] helo=shorty)
 by shorty.local with esmtp (Exim 4.84)
 (envelope-from <dima@HIDDEN>)
 id 1Zrw2k-0000JI-PR; Thu, 29 Oct 2015 15:51:38 -0700
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
 <87lhbqdhjp.fsf@HIDDEN> <83d1x2eugp.fsf@HIDDEN>
 <87oagl376v.fsf@HIDDEN> <560BB690.3020804@HIDDEN>
 <87612q3oxj.fsf@HIDDEN> <560D34CB.5010900@HIDDEN>
 <874mia2zjh.fsf@HIDDEN> <560E106C.6010103@HIDDEN>
From: Dima Kogan <dima@HIDDEN>
To: Dmitry Antipov <dmantipov@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <560E106C.6010103@HIDDEN>
Date: Thu, 29 Oct 2015 15:51:38 -0700
Message-ID: <87r3kdguf9.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Dmitry Antipov <dmantipov@HIDDEN> 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?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.
Changed bug title to '25.0.50; Memory leak in emacs -Q with lucid (font cache cleared prematurely)' from '25.0.50; Memory leak in emacs -Q with lucid (font)' Request was from Dima Kogan <dima@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 2 Oct 2015 18:56:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 02 14:56:56 2015
Received: from localhost ([127.0.0.1]:52422 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Zi5Vo-00074U-8s
	for submit <at> debbugs.gnu.org; Fri, 02 Oct 2015 14:56:56 -0400
Received: from out4-smtp.messagingengine.com ([66.111.4.28]:38332)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dima@HIDDEN>) id 1Zi5Vm-00074M-IJ
 for 21556 <at> debbugs.gnu.org; Fri, 02 Oct 2015 14:56:55 -0400
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.nyi.internal (Postfix) with ESMTP id 521A02099D
 for <21556 <at> debbugs.gnu.org>; Fri,  2 Oct 2015 14:56:54 -0400 (EDT)
Received: from frontend2 ([10.202.2.161])
 by compute2.internal (MEProxy); Fri, 02 Oct 2015 14:56:54 -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=zacPd
 05k4sm2otjcvr2YIKUB4lc=; b=oNihLp9Z5Ucd4oePrVsNNUbl3hx+eZrjbQtNs
 ufCJr2TPeZsHFJ1KrxaZug8zmbcQB3mtKkR6MN5BTKR8aAFOELkLuRAjqr+BX5vM
 YdD1bohod9iO6CmqTDgf6S26RT18SFZuFnvBMEB0GNrWGQ0WZl/yMjhzxH24ru21
 UUulto=
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=zacPd05k4sm2otjcvr2YIKUB4lc=; b=Iz7cu
 L4HpK14l+Vv/B1oTW5aqSYGRWmGZ0pqSqbcf6unZogoq11z7mBxkV+DBKxwFe0UJ
 OrqHltBhWhk/ZsO70iTGRjdaslqxANVitT4FT++qQix0id3VU81tc0XPNKcdldoR
 U034NvfDSA4cVvpbFwW+fOcOlWekHKRh+A0KnI=
X-Sasl-enc: 5QL2uu6TZje2yHolGW2PLbTJ+sEtVKIotdEgddCMq2Ly 1443812214
Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com
 [50.1.153.216])
 by mail.messagingengine.com (Postfix) with ESMTPA id 046B56801D2;
 Fri,  2 Oct 2015 14:56:54 -0400 (EDT)
Received: from ip6-localhost ([::1] helo=shorty)
 by shorty.local with esmtp (Exim 4.84)
 (envelope-from <dima@HIDDEN>)
 id 1Zi5Vk-0005fL-Lw; Fri, 02 Oct 2015 11:56:52 -0700
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
 <87lhbqdhjp.fsf@HIDDEN> <83d1x2eugp.fsf@HIDDEN>
 <87oagl376v.fsf@HIDDEN> <560BB690.3020804@HIDDEN>
 <87612q3oxj.fsf@HIDDEN> <560D34CB.5010900@HIDDEN>
 <874mia2zjh.fsf@HIDDEN> <560E106C.6010103@HIDDEN>
From: Dima Kogan <dima@HIDDEN>
To: Dmitry Antipov <dmantipov@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <560E106C.6010103@HIDDEN>
Date: Fri, 02 Oct 2015 11:56:52 -0700
Message-ID: <87wpv514ln.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Dmitry Antipov <dmantipov@HIDDEN> writes:

> 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.

OK, I need even more clarification here. You're saying that you would
expect both the font entities and the fonts to be marked from
mark_char_table()? How does this relate to Vfontset_table? The code
doesn't make this obvious.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 2 Oct 2015 05:04:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 02 01:04:51 2015
Received: from localhost ([127.0.0.1]:51156 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZhsWY-0001Ou-QL
	for submit <at> debbugs.gnu.org; Fri, 02 Oct 2015 01:04:51 -0400
Received: from forward19h.cmail.yandex.net ([87.250.230.161]:51611)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dmantipov@HIDDEN>) id 1ZhsWW-0001Oj-7V
 for 21556 <at> debbugs.gnu.org; Fri, 02 Oct 2015 01:04:49 -0400
Received: from smtp4h.mail.yandex.net (smtp4h.mail.yandex.net
 [IPv6:2a02:6b8:0:f05::118])
 by forward19h.cmail.yandex.net (Yandex) with ESMTP id CA35C2109E;
 Fri,  2 Oct 2015 08:04:45 +0300 (MSK)
Received: from smtp4h.mail.yandex.net (localhost [127.0.0.1])
 by smtp4h.mail.yandex.net (Yandex) with ESMTP id B3C152C0410;
 Fri,  2 Oct 2015 08:04:44 +0300 (MSK)
Received: by smtp4h.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id
 fC8KGVeYFY-4iAef6cT; Fri,  2 Oct 2015 08:04:44 +0300
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client certificate not present)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1443762284; bh=IDYpLjBGBr6CZFsAADftbR6QFShRLSj9rAvGSkauZbU=;
 h=Subject:To:References:Cc:From:Message-ID:Date:User-Agent:
 MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding;
 b=fXWpMoiXS78BkTQ8plcQPnAg0Z7Ev6jiosf6ls5SKDB0C2tJrS1XR27nNEJ992dBS
 zxiNwVrkQe06dFNqCcn9ui6hPsVSbsub0bXLdH2TlODArrs3PALLrR5pH1TCanCmJy
 5vg/MDc+b+ozPMlZY6bU2T7D1YrRFdWkuuh36uNU=
Authentication-Results: smtp4h.mail.yandex.net; dkim=pass header.i=@yandex.ru
X-Yandex-ForeignMX: US
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
To: Dima Kogan <dima@HIDDEN>
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
 <87lhbqdhjp.fsf@HIDDEN> <83d1x2eugp.fsf@HIDDEN>
 <87oagl376v.fsf@HIDDEN> <560BB690.3020804@HIDDEN>
 <87612q3oxj.fsf@HIDDEN> <560D34CB.5010900@HIDDEN>
 <874mia2zjh.fsf@HIDDEN>
From: Dmitry Antipov <dmantipov@HIDDEN>
Message-ID: <560E106C.6010103@HIDDEN>
Date: Fri, 2 Oct 2015 08:04:44 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.2.0
MIME-Version: 1.0
In-Reply-To: <874mia2zjh.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

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.

Dmitry





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 1 Oct 2015 18:51:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 01 14:51:05 2015
Received: from localhost ([127.0.0.1]:50999 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Zhiwa-000247-Vh
	for submit <at> debbugs.gnu.org; Thu, 01 Oct 2015 14:51:05 -0400
Received: from out1-smtp.messagingengine.com ([66.111.4.25]:58682)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dima@HIDDEN>) id 1ZhiwY-00023w-4W
 for 21556 <at> debbugs.gnu.org; Thu, 01 Oct 2015 14:51:02 -0400
Received: from compute5.internal (compute5.nyi.internal [10.202.2.45])
 by mailout.nyi.internal (Postfix) with ESMTP id BBBCE20881
 for <21556 <at> debbugs.gnu.org>; Thu,  1 Oct 2015 14:51:01 -0400 (EDT)
Received: from frontend1 ([10.202.2.160])
 by compute5.internal (MEProxy); Thu, 01 Oct 2015 14:51:01 -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=j0OO3
 jXrxZP/6YCFr14oGTlQDys=; b=d3ma7NpJjXJgRs04X0jICTaS9TrdM3Zr9IWUl
 Y58dHOqRu7qxjS1/EZYfqqnMN4zTnBb/iYVE0AN5sIn5BJBkwL5LxzMrT7QXdgup
 Y0otUvjTLonszhmfPYmlwERJAEtktoQtwKCFmJwzm4RZ7YNUoyJIhRxmV1mnDMxw
 kd0S0M=
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=j0OO3jXrxZP/6YCFr14oGTlQDys=; b=EjsFj
 biWSPqI2owmEhYaSy5B+lwKpNME8gkWi03UpfCALStydwHUwVF+F2nJHX5k5IBcN
 U1ws8CYw6Q+sSYzUSRI7JlL9F2o/IZZQu7X6Tzx9BPni1lgr6FqLq/I3sMe+wuCF
 aqrjZIPmMJrA1WpHLIUy4wU5havDK7HRZb5OdU=
X-Sasl-enc: vdsCTdiUAG2EmwSQdMKE9ESQCu9j4xYy4KFQbNTqh5o5 1443725461
Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com
 [50.1.153.216])
 by mail.messagingengine.com (Postfix) with ESMTPA id 45D08C00021;
 Thu,  1 Oct 2015 14:51:01 -0400 (EDT)
Received: from ip6-localhost ([::1] helo=shorty)
 by shorty.local with esmtp (Exim 4.84)
 (envelope-from <dima@HIDDEN>)
 id 1ZhiwU-0002jI-CL; Thu, 01 Oct 2015 11:50:58 -0700
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
 <87lhbqdhjp.fsf@HIDDEN> <83d1x2eugp.fsf@HIDDEN>
 <87oagl376v.fsf@HIDDEN> <560BB690.3020804@HIDDEN>
 <87612q3oxj.fsf@HIDDEN> <560D34CB.5010900@HIDDEN>
From: Dima Kogan <dima@HIDDEN>
To: Dmitry Antipov <dmantipov@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <560D34CB.5010900@HIDDEN>
Date: Thu, 01 Oct 2015 11:50:58 -0700
Message-ID: <874mia2zjh.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Dmitry Antipov <dmantipov@HIDDEN> writes:

> On 10/01/2015 12:42 PM, Dima Kogan wrote:
>
>> Clearly in this function we mark the font. We don't obviously mark the
>> containing entity, unless it's one of the face->lface[] elements. If
>> even in this case we're supposed to be marking the entity, where would
>> this be?
>
> Hm...I suppose that all really used font stuff should be marked through
> fontsets (read: char tables, see fontset.c) recorded in Vfontset_table.

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?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 1 Oct 2015 13:27:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 01 09:27:48 2015
Received: from localhost ([127.0.0.1]:50043 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Zhdtj-0006Ek-LA
	for submit <at> debbugs.gnu.org; Thu, 01 Oct 2015 09:27:47 -0400
Received: from forward11m.cmail.yandex.net ([5.255.216.137]:34812)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dmantipov@HIDDEN>) id 1Zhdte-0006EZ-M6
 for 21556 <at> debbugs.gnu.org; Thu, 01 Oct 2015 09:27:44 -0400
Received: from smtp2m.mail.yandex.net (smtp2m.mail.yandex.net
 [IPv6:2a02:6b8:0:2519::122])
 by forward11m.cmail.yandex.net (Yandex) with ESMTP id 68260214BE;
 Thu,  1 Oct 2015 16:27:40 +0300 (MSK)
Received: from smtp2m.mail.yandex.net (localhost [127.0.0.1])
 by smtp2m.mail.yandex.net (Yandex) with ESMTP id BE2BC4267E8;
 Thu,  1 Oct 2015 16:27:39 +0300 (MSK)
Received: by smtp2m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id
 UnJEi23M9x-RdG8mMOl; Thu,  1 Oct 2015 16:27:39 +0300
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client certificate not present)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1443706059; bh=WZLc7//uEHFmWHC2oYiFEpCzBnhwrNCndHpUYQ0NBbU=;
 h=Subject:To:References:Cc:From:Message-ID:Date:User-Agent:
 MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding;
 b=mFmDu/v2THzWrTAx0Q/XdisnXK+uv5ymqiot9++n9ueJS+swH/tBLlSt6/AgnuJA9
 xSgldF0U7gbMIrWlCOdVFQY/isBn907EGrxApXpxw5Wdq1ef2EwSCQVixAxfBf0yf9
 5iHMJyvu44eyjDtpMF/IdOvdnH9i5gC7jwnlmKMw=
Authentication-Results: smtp2m.mail.yandex.net; dkim=pass header.i=@yandex.ru
X-Yandex-ForeignMX: US
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
To: Dima Kogan <dima@HIDDEN>
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
 <87lhbqdhjp.fsf@HIDDEN> <83d1x2eugp.fsf@HIDDEN>
 <87oagl376v.fsf@HIDDEN> <560BB690.3020804@HIDDEN>
 <87612q3oxj.fsf@HIDDEN>
From: Dmitry Antipov <dmantipov@HIDDEN>
Message-ID: <560D34CB.5010900@HIDDEN>
Date: Thu, 1 Oct 2015 16:27:39 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.2.0
MIME-Version: 1.0
In-Reply-To: <87612q3oxj.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

On 10/01/2015 12:42 PM, Dima Kogan wrote:

> Clearly in this function we mark the font. We don't obviously mark the
> containing entity, unless it's one of the face->lface[] elements. If
> even in this case we're supposed to be marking the entity, where would
> this be?

Hm...I suppose that all really used font stuff should be marked through
fontsets (read: char tables, see fontset.c) recorded in Vfontset_table.

Dmitry





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 1 Oct 2015 09:42:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 01 05:42:40 2015
Received: from localhost ([127.0.0.1]:49911 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZhaNr-0007tw-Qm
	for submit <at> debbugs.gnu.org; Thu, 01 Oct 2015 05:42:40 -0400
Received: from out1-smtp.messagingengine.com ([66.111.4.25]:33118)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dima@HIDDEN>) id 1ZhaNp-0007tn-S6
 for 21556 <at> debbugs.gnu.org; Thu, 01 Oct 2015 05:42:38 -0400
Received: from compute2.internal (compute2.nyi.internal [10.202.2.42])
 by mailout.nyi.internal (Postfix) with ESMTP id 48B7D2030C
 for <21556 <at> debbugs.gnu.org>; Thu,  1 Oct 2015 05:42:34 -0400 (EDT)
Received: from frontend2 ([10.202.2.161])
 by compute2.internal (MEProxy); Thu, 01 Oct 2015 05:42:34 -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=0wj47
 6Nr/95hIymGmil3r1eshio=; b=Jer463brPm307t7jTExNxvoMGi/qVVOSPI5Zz
 CX7GlRc+zf6xBTRnyKTEotXLZQ3gJMl+k8Sg/hB0KJEzS8fXicounFN9shgByxXt
 gZ1WIJbz0gJZ6D57hKyBaWrr+nzb68w1VVIDIkuYB/fjH6a7ivZnxk6PIUehLvQT
 y6uQ+s=
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=0wj476Nr/95hIymGmil3r1eshio=; b=CI4M0
 N8KVmbvN+jWvuXdM/GXvUUREU2KDeT8VZqMlWCeWdLXG0h8MwxlLOZxQVgDUCsJt
 c5lSqY4M7tDxzRpmpyZIunefa22ZQgxiOPmay5UZh+HK7lL6JZWyF05aCarBTsp2
 Cq4Q6nDM69ChfTPBDhlprN9ymnKhTwGcY9SuBQ=
X-Sasl-enc: cBxw5RPbTfh+hK5zru3RCCZ3lImBMEEpdsOMySLBJVtV 1443692554
Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com
 [50.1.153.216])
 by mail.messagingengine.com (Postfix) with ESMTPA id 01189680119;
 Thu,  1 Oct 2015 05:42:33 -0400 (EDT)
Received: from ip6-localhost ([::1] helo=shorty)
 by shorty.local with esmtp (Exim 4.84)
 (envelope-from <dima@HIDDEN>)
 id 1ZhaNk-0001nh-Iy; Thu, 01 Oct 2015 02:42:32 -0700
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
 <87lhbqdhjp.fsf@HIDDEN> <83d1x2eugp.fsf@HIDDEN>
 <87oagl376v.fsf@HIDDEN> <560BB690.3020804@HIDDEN>
From: Dima Kogan <dima@HIDDEN>
To: Dmitry Antipov <dmantipov@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <560BB690.3020804@HIDDEN>
Date: Thu, 01 Oct 2015 02:42:32 -0700
Message-ID: <87612q3oxj.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Dmitry Antipov <dmantipov@HIDDEN> writes:

> On 09/29/2015 12:28 PM, Dima Kogan wrote:
>
>> I found and fixed the bug, and the patch is attached. The issue was
>> that the compaction code wasn't checking all the right lisp objects
>> for the marks. The font entities were storing a list of fonts, and
>> this list had to be traversed, looking for the marks.
>
> In general, this patch hits the case where the font object is marked but the
> corresponding font entity is not; but is that legal? IIRC Emacs asks the font
> driver to find a font described by font spec, and returned object is a font entity,
> which is a list of font objects plus some extra stuff. Thus, there should be
> no "free-floating" font objects, i.e. for each font object, there should be
> at least one font entity object which references that font. IOW, having
> marked font object without marked font entity looks like GC mark bug for me.

OK. The target of the patch is as you describe: fonts marked inside an
unmarked entity. I'm observing this situation every time from an emacs
-Q. The font is marked inside mark_face_cache(), which looks like this:


   NO_INLINE /* To reduce stack depth in mark_object.  */
   static void
   mark_face_cache (struct face_cache *c)
   {
     if (c)
       {
         int i, j;
         for (i = 0; i < c->used; ++i)
           {
             struct face *face = FACE_FROM_ID (c->f, i);

             if (face)
               {
                 if (face->font && !VECTOR_MARKED_P (face->font))
                   mark_vectorlike ((struct Lisp_Vector *) face->font);

                 for (j = 0; j < LFACE_VECTOR_SIZE; ++j)
                   mark_object (face->lface[j]);
               }
           }
       }
   }


Clearly in this function we mark the font. We don't obviously mark the
containing entity, unless it's one of the face->lface[] elements. If
even in this case we're supposed to be marking the entity, where would
this be?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 30 Sep 2015 10:16:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 30 06:16:55 2015
Received: from localhost ([127.0.0.1]:48700 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZhERT-0004eR-0r
	for submit <at> debbugs.gnu.org; Wed, 30 Sep 2015 06:16:55 -0400
Received: from forward16h.cmail.yandex.net ([87.250.230.158]:45778)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dmantipov@HIDDEN>) id 1ZhERQ-0004eI-My
 for 21556 <at> debbugs.gnu.org; Wed, 30 Sep 2015 06:16:54 -0400
Received: from smtp2h.mail.yandex.net (smtp2h.mail.yandex.net [84.201.187.145])
 by forward16h.cmail.yandex.net (Yandex) with ESMTP id B67DF20EAB;
 Wed, 30 Sep 2015 13:16:50 +0300 (MSK)
Received: from smtp2h.mail.yandex.net (localhost [127.0.0.1])
 by smtp2h.mail.yandex.net (Yandex) with ESMTP id ACB201700B66;
 Wed, 30 Sep 2015 13:16:49 +0300 (MSK)
Received: by smtp2h.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id
 ORj5ClVnmV-GnfugJRw; Wed, 30 Sep 2015 13:16:49 +0300
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client certificate not present)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail;
 t=1443608209; bh=irubfG952jufGALcfKiAKTfCNv7HTc/9CHAVvqKPDVU=;
 h=Subject:To:References:Cc:From:Message-ID:Date:User-Agent:
 MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding;
 b=D1AhzWz/00ghzwAslqt5THOBmq2fq8Am3cEjKqXhdDdecRlDgKkSaE/87upMZKuaT
 Nvn6sXMLzA93fEXhXtIeylkz5SeI5fHBQ6AjRb9xGLFtphqXIxCBKTV0Os/adgKWp9
 3pl200a13GCR3GfBUGzYak2dYByIapjbmlEM7mjM=
Authentication-Results: smtp2h.mail.yandex.net; dkim=pass header.i=@yandex.ru
X-Yandex-ForeignMX: US
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
To: Dima Kogan <dima@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
 <87lhbqdhjp.fsf@HIDDEN> <83d1x2eugp.fsf@HIDDEN>
 <87oagl376v.fsf@HIDDEN>
From: Dmitry Antipov <dmantipov@HIDDEN>
Message-ID: <560BB690.3020804@HIDDEN>
Date: Wed, 30 Sep 2015 13:16:48 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Thunderbird/38.2.0
MIME-Version: 1.0
In-Reply-To: <87oagl376v.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

On 09/29/2015 12:28 PM, Dima Kogan wrote:

> I guess I preferred to invest more time. I found and fixed the bug, and
> the patch is attached. The issue was that the compaction code wasn't
> checking all the right lisp objects for the marks. The font entities
> were storing a list of fonts, and this list had to be traversed, looking
> for the marks. See font_clear_cache() for a function that WAS traversing
> the full list.

IMO this code should be reworked to omit 'any_fonts_marked' variable :-),
something like:

diff --git a/src/alloc.c b/src/alloc.c
index 3ab2a6e..3109654 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5303,8 +5303,25 @@ compact_font_cache_entry (Lisp_Object entry)
              are not marked too.  But we must be sure that nothing is
              marked within OBJ before we really drop it.  */
           for (i = 0; i < size; i++)
-           if (VECTOR_MARKED_P (XFONT_ENTITY (AREF (XCDR (obj), i))))
-             break;
+            {
+              Lisp_Object objlist;
+
+              if (VECTOR_MARKED_P (XFONT_ENTITY (AREF (XCDR (obj), i))))
+                break;
+
+              objlist = AREF (AREF (XCDR (obj), i), FONT_OBJLIST_INDEX);
+              for (; CONSP (objlist); objlist = XCDR (objlist))
+                {
+                  Lisp_Object val = XCAR (objlist);
+                  struct font *font = XFONT_OBJECT (val);
+
+                  if (! NILP (AREF (val, FONT_TYPE_INDEX)) &&
+                      VECTOR_MARKED_P(font))
+                   break;
+                }
+              if (!NILP (objlist))
+                break;
+            }

           if (i == size)
             drop = 1;


In general, this patch hits the case where the font object is marked but the
corresponding font entity is not; but is that legal? IIRC Emacs asks the font
driver to find a font described by font spec, and returned object is a font entity,
which is a list of font objects plus some extra stuff. Thus, there should be
no "free-floating" font objects, i.e. for each font object, there should be
at least one font entity object which references that font. IOW, having
marked font object without marked font entity looks like GC mark bug for me.

Dmitry





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 30 Sep 2015 07:00:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 30 03:00:52 2015
Received: from localhost ([127.0.0.1]:48525 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZhBNj-0008Hw-VE
	for submit <at> debbugs.gnu.org; Wed, 30 Sep 2015 03:00:52 -0400
Received: from mtaout26.012.net.il ([80.179.55.182]:44967)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1ZhBNh-0008Hl-T3
 for 21556 <at> debbugs.gnu.org; Wed, 30 Sep 2015 03:00:51 -0400
Received: from conversion-daemon.mtaout26.012.net.il by mtaout26.012.net.il
 (HyperSendmail v2007.08) id <0NVH00J009ZQRI00@HIDDEN> for
 21556 <at> debbugs.gnu.org; Wed, 30 Sep 2015 10:03:36 +0300 (IDT)
Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout26.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NVH00KQQAA0C710@HIDDEN>; Wed, 30 Sep 2015 10:03:36 +0300 (IDT)
Date: Wed, 30 Sep 2015 10:00:59 +0300
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <87oagl376v.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Dima Kogan <dima@HIDDEN>
Message-id: <83vbasbdck.fsf@HIDDEN>
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
 <87lhbqdhjp.fsf@HIDDEN> <83d1x2eugp.fsf@HIDDEN>
 <87oagl376v.fsf@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, dmantipov@HIDDEN, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> From: Dima Kogan <dima@HIDDEN>
> Cc: handa@HIDDEN, 21556 <at> debbugs.gnu.org, dmantipov@HIDDEN
> Date: Tue, 29 Sep 2015 02:28:56 -0700
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > So, if you prefer not to invest any time in investigating the font
> > marking code, let's wait for Dmitry to respond, and make the decision
> > when he does (or when we give up waiting).
> 
> I guess I preferred to invest more time. I found and fixed the bug, and
> the patch is attached. The issue was that the compaction code wasn't
> checking all the right lisp objects for the marks. The font entities
> were storing a list of fonts, and this list had to be traversed, looking
> for the marks. See font_clear_cache() for a function that WAS traversing
> the full list.

Thanks!

Let's wait for a week for comments, and if nothing significant comes
up, let's install this.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 29 Sep 2015 10:05:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 29 06:05:46 2015
Received: from localhost ([127.0.0.1]:47285 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Zgrn8-0007FH-K9
	for submit <at> debbugs.gnu.org; Tue, 29 Sep 2015 06:05:46 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39109)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <handa@HIDDEN>) id 1Zgrn7-0007F7-8C
 for 21556 <at> debbugs.gnu.org; Tue, 29 Sep 2015 06:05:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <handa@HIDDEN>) id 1Zgrn1-0006cb-Lo
 for 21556 <at> debbugs.gnu.org; Tue, 29 Sep 2015 06:05:44 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:60944)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <handa@HIDDEN>)
 id 1Zgrmq-0006Qh-50; Tue, 29 Sep 2015 06:05:28 -0400
Received: from fl1-133-203-86-7.iba.mesh.ad.jp ([133.203.86.7]:40678
 helo=shatin)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128)
 (Exim 4.82) (envelope-from <handa@HIDDEN>)
 id 1Zgrmp-0003BA-9O; Tue, 29 Sep 2015 06:05:27 -0400
Received: from handa by shatin with local (Exim 4.82)
 (envelope-from <handa@HIDDEN>)
 id 1Zgrmj-0003vV-7C; Tue, 29 Sep 2015 19:05:21 +0900
From: handa@HIDDEN (K. Handa)
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-Reply-To: <83io6wffm9.fsf@HIDDEN> (message from Eli Zaretskii on Sun,
 27 Sep 2015 11:09:18 +0300)
Date: Tue, 29 Sep 2015 19:05:21 +0900
Message-ID: <87a8s5tuam.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, dmantipov@HIDDEN, dima@HIDDEN,
 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

In article <83io6wffm9.fsf@HIDDEN>, Eli Zaretskii <eliz@HIDDEN> writes:

> So maybe we should simply remove (or ifdef away) the code that
> compacts the font caches.  If your assumption about reusing the font
> is anywhere near the truth, compacting the font cache gives us more
> trouble than it gains: we get slow redisplay in some cases and random
> hard-to-debug bugs, while the gains are only visible in very rare use
> cases such as the one described in the Oct 2013 discussion.

That may be an practical workaround at the moment.

But, my design was based on the situation of more than 10 years.
Nowadays, font listing and loading may not be that slow.  And, if the
cache-compacting code itself is doing the right thing, and it just
revealed a bug in core part of font handler, the effort of tracking down
the reason of current crashing may lead to fixing that bug.

---
K. Handa
handa@HIDDEN




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 29 Sep 2015 09:29:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 29 05:29:03 2015
Received: from localhost ([127.0.0.1]:47262 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZgrDa-0006NP-Pv
	for submit <at> debbugs.gnu.org; Tue, 29 Sep 2015 05:29:03 -0400
Received: from out3-smtp.messagingengine.com ([66.111.4.27]:44576)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dima@HIDDEN>) id 1ZgrDY-0006Mz-Uh
 for 21556 <at> debbugs.gnu.org; Tue, 29 Sep 2015 05:29:01 -0400
Received: from compute6.internal (compute6.nyi.internal [10.202.2.46])
 by mailout.nyi.internal (Postfix) with ESMTP id E1EB520B58
 for <21556 <at> debbugs.gnu.org>; Tue, 29 Sep 2015 05:28:58 -0400 (EDT)
Received: from frontend2 ([10.202.2.161])
 by compute6.internal (MEProxy); Tue, 29 Sep 2015 05:28:58 -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=v7gV1
 n5WKG2NaGYwOT5h19tPlg4=; b=LqCAGOlYkfSeYllpU2ZMrXQ0g/l8QB7vVhQAi
 ljlmJ3gpZjnSg90jZPYIfcinq5HKkxh9ifEd2AyC095gTkC9XDf8EyK8nrgpe5d8
 aj7AXkS0b9LX41JxyskHhOSf82xRdmlIt7X8oNIv07LgPdDed2azHs3X1oq7wa8W
 RosIiY=
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=v7gV1n5WKG2NaGYwOT5h19tPlg4=; b=jsGtV
 B9ViUwXqWjWFYTXfaSfq/V5eW93YvZW72F0nKI6iOFVn3UkpPLM1W7Qq7fH3Ayvi
 /BsbjdtO08pkrMpRRDYFUMfgf8sB8GvVECnCBPMI06sb8E29Yz9NvyfNcLGulx8+
 S5UVZ3bhyfXs7q9K87zk6GIcSzXZ3fbNW5Jy+0=
X-Sasl-enc: T8MTT33s2KkCPNFXNuYvirOnBqBpHlpaVQ9dgLazdk7P 1443518938
Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com
 [50.1.153.216])
 by mail.messagingengine.com (Postfix) with ESMTPA id 8762F680117;
 Tue, 29 Sep 2015 05:28:58 -0400 (EDT)
Received: from ip6-localhost ([::1] helo=shorty)
 by shorty.local with esmtp (Exim 4.84)
 (envelope-from <dima@HIDDEN>)
 id 1ZgrDU-0007jp-U2; Tue, 29 Sep 2015 02:28:56 -0700
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
 <87lhbqdhjp.fsf@HIDDEN> <83d1x2eugp.fsf@HIDDEN>
From: Dima Kogan <dima@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <83d1x2eugp.fsf@HIDDEN>
Date: Tue, 29 Sep 2015 02:28:56 -0700
Message-ID: <87oagl376v.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, dmantipov@HIDDEN, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

--=-=-=
Content-Type: text/plain

Eli Zaretskii <eliz@HIDDEN> writes:

> So, if you prefer not to invest any time in investigating the font
> marking code, let's wait for Dmitry to respond, and make the decision
> when he does (or when we give up waiting).

I guess I preferred to invest more time. I found and fixed the bug, and
the patch is attached. The issue was that the compaction code wasn't
checking all the right lisp objects for the marks. The font entities
were storing a list of fonts, and this list had to be traversed, looking
for the marks. See font_clear_cache() for a function that WAS traversing
the full list.

I'm certain there are more leaks here, but bug 21509 is now the main
leaker with my current test case.



--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline;
 filename=0001-compact_font_cache_entry-now-properly-checks-for-mar.patch

From e9b0394826c4e706550259cd3862a89343c6cf2b Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@HIDDEN>
Date: Tue, 29 Sep 2015 02:19:35 -0700
Subject: [PATCH] compact_font_cache_entry() now properly checks for marked
 fonts

* src/alloc.c (compact_font_cache_entry): When checking for marked
fonts we were looking at a font entity object.  However the entity
could contain a list of font objects that need to be checked, which we
now do.  This resolves a memory leak
Fixes: bug#21556
---
 src/alloc.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 3ab2a6e..03df258 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5303,8 +5303,31 @@ compact_font_cache_entry (Lisp_Object entry)
 	     are not marked too.  But we must be sure that nothing is
 	     marked within OBJ before we really drop it.  */
 	  for (i = 0; i < size; i++)
-	    if (VECTOR_MARKED_P (XFONT_ENTITY (AREF (XCDR (obj), i))))
-	      break;
+            {
+              Lisp_Object objlist;
+              bool any_fonts_marked;
+
+              if (VECTOR_MARKED_P (XFONT_ENTITY (AREF (XCDR (obj), i))))
+                break;
+
+              objlist = AREF (AREF (XCDR (obj), i), FONT_OBJLIST_INDEX);
+              any_fonts_marked = false;
+
+              for (; CONSP (objlist); objlist = XCDR (objlist))
+                {
+                  Lisp_Object val = XCAR (objlist);
+                  struct font *font = XFONT_OBJECT (val);
+
+                  if (! NILP (AREF (val, FONT_TYPE_INDEX)) &&
+                      VECTOR_MARKED_P(font))
+                    {
+                      any_fonts_marked = true;
+                      break;
+                    }
+                }
+              if(any_fonts_marked)
+                break;
+            }
 
 	  if (i == size)
 	    drop = 1;
-- 
2.1.4


--=-=-=--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 28 Sep 2015 09:58:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 28 05:58:24 2015
Received: from localhost ([127.0.0.1]:46229 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZgVCR-0005QG-IJ
	for submit <at> debbugs.gnu.org; Mon, 28 Sep 2015 05:58:23 -0400
Received: from mtaout29.012.net.il ([80.179.55.185]:58014)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1ZgVCP-0005Q4-1r
 for 21556 <at> debbugs.gnu.org; Mon, 28 Sep 2015 05:58:22 -0400
Received: from conversion-daemon.mtaout29.012.net.il by mtaout29.012.net.il
 (HyperSendmail v2007.08) id <0NVD00P00SUU6100@HIDDEN> for
 21556 <at> debbugs.gnu.org; Mon, 28 Sep 2015 12:59:07 +0300 (IDT)
Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout29.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NVD0054HT2J6HD0@HIDDEN>; Mon, 28 Sep 2015 12:59:07 +0300 (IDT)
Date: Mon, 28 Sep 2015 12:58:30 +0300
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <87lhbqdhjp.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Dima Kogan <dima@HIDDEN>
Message-id: <83d1x2eugp.fsf@HIDDEN>
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
 <87lhbqdhjp.fsf@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 21556
Cc: handa@HIDDEN, dmantipov@HIDDEN, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> From: Dima Kogan <dima@HIDDEN>
> Cc: "K. Handa" <handa@HIDDEN>, 21556 <at> debbugs.gnu.org, dmantipov@HIDDEN
> Date: Mon, 28 Sep 2015 02:22:50 -0700
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > So maybe we should simply remove (or ifdef away) the code that
> > compacts the font caches.  If your assumption about reusing the font
> > is anywhere near the truth, compacting the font cache gives us more
> > trouble than it gains: we get slow redisplay in some cases and random
> > hard-to-debug bugs, while the gains are only visible in very rare use
> > cases such as the one described in the Oct 2013 discussion.
> 
> Hi. I put in some more probes, and it looks like the fonts aren't being
> marked as used properly. I also wrote a bit of code to make the gc
> actually free fonts it drops. Unsurprisingly, this causes things to
> crash, since it then frees fonts that are actually in use. Does it make
> sense to track down why the fonts aren't marked as used? If the
> compaction code goes away, then it doesn't really matter.

It depends on how much time and energy do you have.  I think it would
be nice to understand where and how do we mark used fonts, if only to
document that and make sure we don't miss anything.  However, my
personal preference is to remove the cache compaction, unless we hear
some good reasons from Dmitry, and some ideas for how to fix the
leaks.

So, if you prefer not to invest any time in investigating the font
marking code, let's wait for Dmitry to respond, and make the decision
when he does (or when we give up waiting).

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 28 Sep 2015 09:22:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 28 05:22:56 2015
Received: from localhost ([127.0.0.1]:46221 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZgUe8-000482-5M
	for submit <at> debbugs.gnu.org; Mon, 28 Sep 2015 05:22:56 -0400
Received: from out3-smtp.messagingengine.com ([66.111.4.27]:52392)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dima@HIDDEN>) id 1ZgUe5-00047q-OG
 for 21556 <at> debbugs.gnu.org; Mon, 28 Sep 2015 05:22:54 -0400
Received: from compute4.internal (compute4.nyi.internal [10.202.2.44])
 by mailout.nyi.internal (Postfix) with ESMTP id BAC46204A5
 for <21556 <at> debbugs.gnu.org>; Mon, 28 Sep 2015 05:22:52 -0400 (EDT)
Received: from frontend2 ([10.202.2.161])
 by compute4.internal (MEProxy); Mon, 28 Sep 2015 05:22:52 -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=Y9wqF
 YoktadMdWS2Nu/SD7AsViM=; b=VuIJCilp14hR8UuDE0Aldr06J2IC+EyIJPGmf
 Z2hjB2+ync9V8yqqBAzOVG+AvJx9/kh/6OcQ/ob1J6LnE3tPnw2gZZ6VJNmgYcra
 A4THie4nXPeWb+V8aW7sqc5SGP6+/lq6vi237ARUs+EiRRE1744Rep81/6yEFLwH
 Ald3sw=
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=Y9wqFYoktadMdWS2Nu/SD7AsViM=; b=IRoB7
 G0DTudJLi10jjPgkZMNmJqXZa3cowdm7Uks2onDRgaSMclAF/R3fWMfSX95aVXBy
 TqM+5/dBBsKqdDBCznRTRDzW49ra6gPwOOuoiKGmQivQa+28Dc9G4t6DoG+vtWGl
 HBNUuCJVMiAS4fHcVz3aZ3hrY42O9I0+rMxdgs=
X-Sasl-enc: 8byYE8jprlj/GtDxTjSkP4OysfS+in5HrIrPbeqjADaM 1443432172
Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com
 [50.1.153.216])
 by mail.messagingengine.com (Postfix) with ESMTPA id 5BA0A68012C;
 Mon, 28 Sep 2015 05:22:52 -0400 (EDT)
Received: from localhost ([::1] helo=shorty)
 by shorty.local with esmtp (Exim 4.84)
 (envelope-from <dima@HIDDEN>)
 id 1ZgUe2-0003pP-Tr; Mon, 28 Sep 2015 02:22:50 -0700
References: <87zj082t34.fsf@HIDDEN> <83io6wffm9.fsf@HIDDEN>
From: Dima Kogan <dima@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <83io6wffm9.fsf@HIDDEN>
Date: Mon, 28 Sep 2015 02:22:50 -0700
Message-ID: <87lhbqdhjp.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21556
Cc: "K. Handa" <handa@HIDDEN>, dmantipov@HIDDEN, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> So maybe we should simply remove (or ifdef away) the code that
> compacts the font caches.  If your assumption about reusing the font
> is anywhere near the truth, compacting the font cache gives us more
> trouble than it gains: we get slow redisplay in some cases and random
> hard-to-debug bugs, while the gains are only visible in very rare use
> cases such as the one described in the Oct 2013 discussion.

Hi. I put in some more probes, and it looks like the fonts aren't being
marked as used properly. I also wrote a bit of code to make the gc
actually free fonts it drops. Unsurprisingly, this causes things to
crash, since it then frees fonts that are actually in use. Does it make
sense to track down why the fonts aren't marked as used? If the
compaction code goes away, then it doesn't really matter.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 27 Sep 2015 08:09:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 27 04:09:28 2015
Received: from localhost ([127.0.0.1]:45493 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Zg71T-0005om-GA
	for submit <at> debbugs.gnu.org; Sun, 27 Sep 2015 04:09:27 -0400
Received: from mtaout24.012.net.il ([80.179.55.180]:46374)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1Zg71Q-0005oc-8K
 for 21556 <at> debbugs.gnu.org; Sun, 27 Sep 2015 04:09:25 -0400
Received: from conversion-daemon.mtaout24.012.net.il by mtaout24.012.net.il
 (HyperSendmail v2007.08) id <0NVB00400SX6EC00@HIDDEN> for
 21556 <at> debbugs.gnu.org; Sun, 27 Sep 2015 11:02:10 +0300 (IDT)
Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout24.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NVB00MNRSZMEC30@HIDDEN>; Sun, 27 Sep 2015 11:02:10 +0300 (IDT)
Date: Sun, 27 Sep 2015 11:09:18 +0300
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <87zj082t34.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: handa@HIDDEN (K. Handa), Dima Kogan <dima@HIDDEN>
Message-id: <83io6wffm9.fsf@HIDDEN>
References: <87zj082t34.fsf@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 21556
Cc: dmantipov@HIDDEN, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> From: handa@HIDDEN (K. Handa)
> Cc: 21556 <at> debbugs.gnu.org, dmantipov@HIDDEN
> Date: Sun, 27 Sep 2015 16:56:47 +0900
> 
> When I wrote the original code long ago, font listing and opening
> was very slow on GNU/Linux system.  So I tried to cache the result
> of listing as far as possible, and also tried to reuse the once
> opened font object as far as possible.  The latter means that even
> if a font object once created becomes unnecessary (perhaps because a
> frame is deleted), it is not freed, because, once a user displayed a
> specific character, it is displayed again with a very high
> possibility.  So, when a font is closed?  It is closed by an
> explicit call of clear-font-fache.  As far as I remember (though
> vaguely), that was my original intention.

So maybe we should simply remove (or ifdef away) the code that
compacts the font caches.  If your assumption about reusing the font
is anywhere near the truth, compacting the font cache gives us more
trouble than it gains: we get slow redisplay in some cases and random
hard-to-debug bugs, while the gains are only visible in very rare use
cases such as the one described in the Oct 2013 discussion.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 27 Sep 2015 07:57:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 27 03:57:03 2015
Received: from localhost ([127.0.0.1]:45484 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Zg6pT-0005W9-1W
	for submit <at> debbugs.gnu.org; Sun, 27 Sep 2015 03:57:03 -0400
Received: from eggs.gnu.org ([208.118.235.92]:41571)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <handa@HIDDEN>) id 1Zg6pQ-0005Vj-Ax
 for 21556 <at> debbugs.gnu.org; Sun, 27 Sep 2015 03:57:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <handa@HIDDEN>) id 1Zg6pL-0007v7-05
 for 21556 <at> debbugs.gnu.org; Sun, 27 Sep 2015 03:56:59 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:53568)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <handa@HIDDEN>)
 id 1Zg6pK-0007v3-TE; Sun, 27 Sep 2015 03:56:54 -0400
Received: from fl1-133-203-86-7.iba.mesh.ad.jp ([133.203.86.7]:58059
 helo=shatin)
 by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128)
 (Exim 4.82) (envelope-from <handa@HIDDEN>)
 id 1Zg6pJ-0005p5-Pb; Sun, 27 Sep 2015 03:56:54 -0400
Received: from handa by shatin with local (Exim 4.82)
 (envelope-from <handa@HIDDEN>)
 id 1Zg6pD-0002LF-QL; Sun, 27 Sep 2015 16:56:47 +0900
From: handa@HIDDEN (K. Handa)
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-Reply-To: <83y4ftfbjw.fsf@HIDDEN> (message from Eli Zaretskii on Sat,
 26 Sep 2015 18:24:51 +0300)
Date: Sun, 27 Sep 2015 16:56:47 +0900
Message-ID: <87zj082t34.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -6.0 (------)
X-Debbugs-Envelope-To: 21556
Cc: dmantipov@HIDDEN, 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

In article <83y4ftfbjw.fsf@HIDDEN>, Eli Zaretskii <eliz@HIDDEN> writes:

> > > I guess I still don't know if the fonts are supposed to be marked or
> > > not. They appear to never be marked. Do you know where that is supposed
> > > to happen?
> > > 
> > > Furthermore, the compaction code is incomplete, at least for xft. Xft
> > > refence-counts the fonts, so you must close all fonts you have opened.
> > > Emacs stores the fonts that have been opened in the cache, so if it ever
> > > drops any fonts from the cache, it must tell xft to close, or else
> > > things leak, as we're seeing. I haven't tried to do this yet, but I
> > > suspect that the fonts should be marked, otherwise we'd be closing the
> > > font that we have just opened.

As the font compaction code (and some other work related to clearing
font cache) is done by Dmitry, I included him in CC:.

> > Originally, font caches were not compacted at all until that
> > discussion in Oct 2013; they are still not compacted now on w32.  To
> > figure out how to compact those caches correctly, I think we need to
> > start with the basics, and understand well the "life cycle" of a font
> > in Emacs, including its font-cache entries: when and how a font is
> > opened and registered in the cache, when and how (and whether) it is
> > closed and removed from the cache, etc.  This stuff is notoriously
> > under-documented in Emacs, and we no longer have active maintainers on
> > board who are familiar with it.
> > 
> > So I'm afraid we are on our own wrt these issues.  (I'm CC'ing
> > Handa-san, who wrote most of the font-related code, in the hope that
> > he could chime in at some point and help us.)

I feel very guilty for those under-documented codes.  When I wrote the
original code long ago, font listing and opening was very slow on
GNU/Linux system.  So I tried to cache the result of listing as far as
possible, and also tried to reuse the once opened font object as far as
possible.  The latter means that even if a font object once created
becomes unnecessary (perhaps because a frame is deleted), it is not
freed, because, once a user displayed a specific character, it is
displayed again with a very high possibility.  So, when a font is
closed?  It is closed by an explicit call of clear-font-fache.  As far
as I remember (though vaguely), that was my original intention.

---
K. Handa
handa@HIDDEN




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 25 Sep 2015 10:03:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 25 06:03:58 2015
Received: from localhost ([127.0.0.1]:42535 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZfPrB-0006WS-Vu
	for submit <at> debbugs.gnu.org; Fri, 25 Sep 2015 06:03:58 -0400
Received: from mtaout20.012.net.il ([80.179.55.166]:54126)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1ZfPr9-0006WJ-89
 for 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 06:03:56 -0400
Received: from conversion-daemon.a-mtaout20.012.net.il by
 a-mtaout20.012.net.il (HyperSendmail v2007.08) id
 <0NV800G008UCGF00@HIDDEN> for 21556 <at> debbugs.gnu.org;
 Fri, 25 Sep 2015 13:03:49 +0300 (IDT)
Received: from HOME-C4E4A596F7 ([84.94.185.246]) by a-mtaout20.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NV800G399ADH510@HIDDEN>;
 Fri, 25 Sep 2015 13:03:49 +0300 (IDT)
Date: Fri, 25 Sep 2015 13:03:53 +0300
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <87zj0adewq.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Dima Kogan <dima@HIDDEN>
Message-id: <837fneizna.fsf@HIDDEN>
References: <87d1x7e53b.fsf@HIDDEN> <83k2rfhu93.fsf@HIDDEN>
 <871tdmex2c.fsf@HIDDEN> <83d1x6j339.fsf@HIDDEN>
 <83bncqj24y.fsf@HIDDEN> <87zj0adewq.fsf@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 21556
Cc: 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> From: Dima Kogan <dima@HIDDEN>
> Cc: 21556 <at> debbugs.gnu.org
> Date: Fri, 25 Sep 2015 02:30:45 -0700
> 
> I guess I still don't know if the fonts are supposed to be marked or
> not. They appear to never be marked. Do you know where that is supposed
> to happen?

See the commentary at the beginning of font.h: a font object is a
pseudo-vector.  So I guess fonts should be marked where pseudo-vectors
are.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 25 Sep 2015 09:45:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 25 05:45:18 2015
Received: from localhost ([127.0.0.1]:42520 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZfPZ7-0004VS-Ry
	for submit <at> debbugs.gnu.org; Fri, 25 Sep 2015 05:45:18 -0400
Received: from mtaout22.012.net.il ([80.179.55.172]:62231)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1ZfPZ5-0004VJ-DO
 for 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 05:45:16 -0400
Received: from conversion-daemon.a-mtaout22.012.net.il by
 a-mtaout22.012.net.il (HyperSendmail v2007.08) id
 <0NV800H008AMHW00@HIDDEN> for 21556 <at> debbugs.gnu.org;
 Fri, 25 Sep 2015 12:45:07 +0300 (IDT)
Received: from HOME-C4E4A596F7 ([84.94.185.246]) by a-mtaout22.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NV800H5J8F7H020@HIDDEN>;
 Fri, 25 Sep 2015 12:45:07 +0300 (IDT)
Date: Fri, 25 Sep 2015 12:45:11 +0300
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <87zj0adewq.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Dima Kogan <dima@HIDDEN>
Message-id: <83a8saj0ig.fsf@HIDDEN>
References: <87d1x7e53b.fsf@HIDDEN> <83k2rfhu93.fsf@HIDDEN>
 <871tdmex2c.fsf@HIDDEN> <83d1x6j339.fsf@HIDDEN>
 <83bncqj24y.fsf@HIDDEN> <87zj0adewq.fsf@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 21556
Cc: 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> From: Dima Kogan <dima@HIDDEN>
> Cc: 21556 <at> debbugs.gnu.org
> Date: Fri, 25 Sep 2015 02:30:45 -0700
> 
> I guess I still don't know if the fonts are supposed to be marked or
> not. They appear to never be marked. Do you know where that is supposed
> to happen?
> 
> Furthermore, the compaction code is incomplete, at least for xft. Xft
> refence-counts the fonts, so you must close all fonts you have opened.
> Emacs stores the fonts that have been opened in the cache, so if it ever
> drops any fonts from the cache, it must tell xft to close, or else
> things leak, as we're seeing. I haven't tried to do this yet, but I
> suspect that the fonts should be marked, otherwise we'd be closing the
> font that we have just opened.

Originally, font caches were not compacted at all until that
discussion in Oct 2013; they are still not compacted now on w32.  To
figure out how to compact those caches correctly, I think we need to
start with the basics, and understand well the "life cycle" of a font
in Emacs, including its font-cache entries: when and how a font is
opened and registered in the cache, when and how (and whether) it is
closed and removed from the cache, etc.  This stuff is notoriously
under-documented in Emacs, and we no longer have active maintainers on
board who are familiar with it.

So I'm afraid we are on our own wrt these issues.  (I'm CC'ing
Handa-san, who wrote most of the font-related code, in the hope that
he could chime in at some point and help us.)  I can offer whatever
help I can extend, which is admittedly not too much.  If you have time
and motivation, I suggest to start from the end: i.e., figure out when
and how a font is closed and removed from Emacs.  If we are lucky,
perhaps the font cache compaction could be triggered by whatever
triggers a font's removal from Emacs.

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 25 Sep 2015 09:30:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 25 05:30:51 2015
Received: from localhost ([127.0.0.1]:42513 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZfPL9-0004Ab-1r
	for submit <at> debbugs.gnu.org; Fri, 25 Sep 2015 05:30:51 -0400
Received: from out3-smtp.messagingengine.com ([66.111.4.27]:48629)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dima@HIDDEN>) id 1ZfPL6-0004AS-RH
 for 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 05:30:49 -0400
Received: from compute3.internal (compute3.nyi.internal [10.202.2.43])
 by mailout.nyi.internal (Postfix) with ESMTP id E4F0520448
 for <21556 <at> debbugs.gnu.org>; Fri, 25 Sep 2015 05:30:46 -0400 (EDT)
Received: from frontend2 ([10.202.2.161])
 by compute3.internal (MEProxy); Fri, 25 Sep 2015 05:30:46 -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=th6bT
 XHl4o/x/7B15HtAxCSF/RI=; b=QuA+1y9T54VVaL2yLaYjigAdi/qwRnHvjHD8w
 GCZfIiTeDW+Usi6VveQtldSEaPnGvHuRCJOnamv8qPkEyKgHvxkZJFDF2Jc9pldX
 5pkZpl7o24HdHSinkbm6Aa9I+ND1Fnex2SJd5t89BsyipnU1CKh3AJp9VYjkAoH9
 CNZ304=
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=th6bTXHl4o/x/7B15HtAxCSF/RI=; b=gSET0
 lj+H0/CU8Ml88U0r5D8r5QAElmzhUoPwlXKwcrl+GS6+XRFCObwO1CHzFxvkYxV7
 MuzhJq10IxtgUKYOyj1ey7XTLhyK515Tm0J/l9KiRuQARhJCxDAAXzcoNzfq8JVo
 xpmFwOsn6ujb/HSbOnsLg+CondbYeqjVutzWZM=
X-Sasl-enc: vh5bpE3pNRgAnSz7yH9WcRkJnV/h3pGpVuuH7Bg0Yo+Y 1443173446
Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com
 [50.1.153.216])
 by mail.messagingengine.com (Postfix) with ESMTPA id 9C2D0680170;
 Fri, 25 Sep 2015 05:30:46 -0400 (EDT)
Received: from ip6-localhost ([::1] helo=shorty)
 by shorty.local with esmtp (Exim 4.84)
 (envelope-from <dima@HIDDEN>)
 id 1ZfPL3-00069l-GM; Fri, 25 Sep 2015 02:30:45 -0700
References: <87d1x7e53b.fsf@HIDDEN> <83k2rfhu93.fsf@HIDDEN>
 <871tdmex2c.fsf@HIDDEN> <83d1x6j339.fsf@HIDDEN>
 <83bncqj24y.fsf@HIDDEN>
From: Dima Kogan <dima@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <83bncqj24y.fsf@HIDDEN>
Date: Fri, 25 Sep 2015 02:30:45 -0700
Message-ID: <87zj0adewq.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21556
Cc: 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

>> cache: the garbage collector. The backtrace in question:
>> 
>>     0x00000000005d2172 in compact_font_cache_entry (entry=24121763) at alloc.c:5313
>
> Yes, that's what I wrote to you you meanwhile.
>
> This seems to mean that fonts whose entries in the cache are not
> marked are still being used, or are unused but not freed.

You called it exactly.

> Some additional background for these issues:

Thanks. Very useful.

I guess I still don't know if the fonts are supposed to be marked or
not. They appear to never be marked. Do you know where that is supposed
to happen?

Furthermore, the compaction code is incomplete, at least for xft. Xft
refence-counts the fonts, so you must close all fonts you have opened.
Emacs stores the fonts that have been opened in the cache, so if it ever
drops any fonts from the cache, it must tell xft to close, or else
things leak, as we're seeing. I haven't tried to do this yet, but I
suspect that the fonts should be marked, otherwise we'd be closing the
font that we have just opened.






Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 25 Sep 2015 09:10:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 25 05:10:06 2015
Received: from localhost ([127.0.0.1]:42496 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZfP13-0003gX-Um
	for submit <at> debbugs.gnu.org; Fri, 25 Sep 2015 05:10:06 -0400
Received: from mtaout29.012.net.il ([80.179.55.185]:53556)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1ZfP10-0003g9-PF
 for 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 05:10:04 -0400
Received: from conversion-daemon.mtaout29.012.net.il by mtaout29.012.net.il
 (HyperSendmail v2007.08) id <0NV800A006PSRF00@HIDDEN> for
 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 12:10:45 +0300 (IDT)
Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout29.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NV8008LN6TW3T20@HIDDEN>; Fri, 25 Sep 2015 12:10:45 +0300 (IDT)
Date: Fri, 25 Sep 2015 12:10:05 +0300
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <83d1x6j339.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: dima@HIDDEN
Message-id: <83bncqj24y.fsf@HIDDEN>
References: <87d1x7e53b.fsf@HIDDEN> <83k2rfhu93.fsf@HIDDEN>
 <871tdmex2c.fsf@HIDDEN> <83d1x6j339.fsf@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 21556
Cc: 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> Date: Fri, 25 Sep 2015 11:49:30 +0300
> From: Eli Zaretskii <eliz@HIDDEN>
> Cc: 21556 <at> debbugs.gnu.org
> 
> > From: Dima Kogan <dima@HIDDEN>
> > Cc: 21556 <at> debbugs.gnu.org
> > Date: Fri, 25 Sep 2015 01:13:15 -0700
> > 
> > Hi. I just came back to this, figured out how to (semi-manually) put in
> > a watchpoint, and this watchpoint told me what's resetting the font
> > cache: the garbage collector. The backtrace in question:
> > 
> >     0x00000000005d2172 in compact_font_cache_entry (entry=24121763) at alloc.c:5313
> >     #0  0x00000000005d2172 in compact_font_cache_entry (entry=24121763) at alloc.c:5313
> >     #1  0x00000000005d221b in compact_font_caches () at alloc.c:5339
> >     #2  0x00000000005d2742 in garbage_collect_1 (end=0x7ffcdb166830) at alloc.c:5515
> >     #3  0x00000000005d2e1d in Fgarbage_collect () at alloc.c:5720
> >     #4  0x000000000054eb21 in maybe_gc () at lisp.h:4515
> >     #5  0x00000000005f638c in Ffuncall (nargs=3, args=0x7ffcdb166988) at eval.c:2584
> 
> Yes, that's what I wrote to you you meanwhile.
> 
> This seems to mean that fonts whose entries in the cache are not
> marked are still being used, or are unused but not freed.

Some additional background for these issues:

This is why the font cache compaction was introduced:

   http://lists.gnu.org/archive/html/emacs-devel/2013-10/msg00740.html

Here's one problem caused by the compaction code, and some followup
discussions with perhaps useful debug code:

   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15876#77

This is another related bug, which eventually caused the font cache
compaction be ifdef'ed away for MS-Windows:

   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16140




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 25 Sep 2015 08:49:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 25 04:49:30 2015
Received: from localhost ([127.0.0.1]:42475 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZfOh8-0003DK-3g
	for submit <at> debbugs.gnu.org; Fri, 25 Sep 2015 04:49:30 -0400
Received: from mtaout29.012.net.il ([80.179.55.185]:49846)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1ZfOh5-0003DB-PW
 for 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 04:49:28 -0400
Received: from conversion-daemon.mtaout29.012.net.il by mtaout29.012.net.il
 (HyperSendmail v2007.08) id <0NV8006005PGK400@HIDDEN> for
 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 11:50:10 +0300 (IDT)
Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout29.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NV800K485VL7WB0@HIDDEN>; Fri, 25 Sep 2015 11:50:10 +0300 (IDT)
Date: Fri, 25 Sep 2015 11:49:30 +0300
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <871tdmex2c.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Dima Kogan <dima@HIDDEN>
Message-id: <83d1x6j339.fsf@HIDDEN>
References: <87d1x7e53b.fsf@HIDDEN> <83k2rfhu93.fsf@HIDDEN>
 <871tdmex2c.fsf@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 21556
Cc: 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> From: Dima Kogan <dima@HIDDEN>
> Cc: 21556 <at> debbugs.gnu.org
> Date: Fri, 25 Sep 2015 01:13:15 -0700
> 
> Hi. I just came back to this, figured out how to (semi-manually) put in
> a watchpoint, and this watchpoint told me what's resetting the font
> cache: the garbage collector. The backtrace in question:
> 
>     0x00000000005d2172 in compact_font_cache_entry (entry=24121763) at alloc.c:5313
>     #0  0x00000000005d2172 in compact_font_cache_entry (entry=24121763) at alloc.c:5313
>     #1  0x00000000005d221b in compact_font_caches () at alloc.c:5339
>     #2  0x00000000005d2742 in garbage_collect_1 (end=0x7ffcdb166830) at alloc.c:5515
>     #3  0x00000000005d2e1d in Fgarbage_collect () at alloc.c:5720
>     #4  0x000000000054eb21 in maybe_gc () at lisp.h:4515
>     #5  0x00000000005f638c in Ffuncall (nargs=3, args=0x7ffcdb166988) at eval.c:2584

Yes, that's what I wrote to you you meanwhile.

This seems to mean that fonts whose entries in the cache are not
marked are still being used, or are unused but not freed.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 25 Sep 2015 08:44:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 25 04:44:12 2015
Received: from localhost ([127.0.0.1]:42471 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZfOc0-00034n-5A
	for submit <at> debbugs.gnu.org; Fri, 25 Sep 2015 04:44:12 -0400
Received: from mtaout27.012.net.il ([80.179.55.183]:42762)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1ZfObx-00034c-C8
 for 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 04:44:10 -0400
Received: from conversion-daemon.mtaout27.012.net.il by mtaout27.012.net.il
 (HyperSendmail v2007.08) id <0NV8002005ABH400@HIDDEN> for
 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 11:40:26 +0300 (IDT)
Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout27.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NV8000B35FEJU20@HIDDEN>; Fri, 25 Sep 2015 11:40:26 +0300 (IDT)
Date: Fri, 25 Sep 2015 11:44:11 +0300
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <8737y3dm0z.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Dima Kogan <dima@HIDDEN>
Message-id: <83eghmj3c4.fsf@HIDDEN>
References: <87d1x7e53b.fsf@HIDDEN> <83k2rfhu93.fsf@HIDDEN>
 <8737y3dm0z.fsf@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 21556
Cc: 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> From: Dima Kogan <dima@HIDDEN>
> Cc: 21556 <at> debbugs.gnu.org
> Date: Thu, 24 Sep 2015 23:57:00 -0700
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> >> Is there a way to put a watchpoint on a lisp object? How?
> >
> > Depends on the object.  Which object do you want to put the watchpoint
> > on?  Please show its source variable name and the source file lines
> > where it is used.  Also, if the object is complex, what kinds of
> > changes in it would you like to watch?
> 
> The object is the emacs font cache. Specifically in this case (Debian,
> X11, xft fonts, lucid widgets) it is
> 
>   frame->output_data.x->display_info->name_list_element
> 
> where frame is a struct frame*, such as the first argument of
> 
>   font_load_for_lface()
> 
> In the original message for this bug report I showed 'pp' output for
> this first argument of font_load_for_lface(). This function is called 4
> times during the creation of one frame. I want to know why the font
> cache is cleared before the 3rd call. I tried to examine the code, and
> to place breakpoints in places that could be performing this cache
> clear, but none of those places look like the right ones. If a
> watchpoint is possible, it would tell me where this is cleared, instead
> of me having to guess.

The place where the font cache is "cleared" (actually, it's compacted)
is in compact_font_caches, and specifically in its subroutine
compact_font_cache_entry.  Did you place breakpoints there, and if so,
what did you see?

If the breakpoints in those functions don't help, then you'd need to
put 2 watchpoints: one at the cdr pointer of (xft 1 ...) list, the
other at the object pointed by that pointer.  You can get at the
values of these by using the GDB commands "xcar", "xcdr", and "xcons",
starting with

  (gdb) p TERMINAL_FONT_CACHE(FRAME_TERMINAL(f))

which will display (the EMACS_INT value of) the object you showed in
your previous message.  Use xcdr to get to the tail of the list which
you want to watch, then use xcar to show the element and xcons to
display its C internals.

Once you discover the addresses of the 2 values, set the watchpoints
on their numerical addresses, do not use the variable names.
Something like this:

  (gdb) watch *(struct Lisp_Cons *) 0x12345676887654320

(If you do want to use the variable names, use "watch -l" to place the
watchpoints on their locations.)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 25 Sep 2015 08:13:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 25 04:13:31 2015
Received: from localhost ([127.0.0.1]:42453 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZfO8I-0002Kv-HM
	for submit <at> debbugs.gnu.org; Fri, 25 Sep 2015 04:13:30 -0400
Received: from out3-smtp.messagingengine.com ([66.111.4.27]:51664)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dima@HIDDEN>) id 1ZfO8G-0002Ko-NH
 for 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 04:13:29 -0400
Received: from compute4.internal (compute4.nyi.internal [10.202.2.44])
 by mailout.nyi.internal (Postfix) with ESMTP id F2AA6202CC
 for <21556 <at> debbugs.gnu.org>; Fri, 25 Sep 2015 04:13:26 -0400 (EDT)
Received: from frontend2 ([10.202.2.161])
 by compute4.internal (MEProxy); Fri, 25 Sep 2015 04:13:26 -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=H522P
 gMspmd9GHaJ8O2jbDyNrus=; b=GyiHE+ELK4S0rXphde/KCJwNdmbCZtH8rFBr5
 azE2kFzzbkbIgRbtooI/b+WNi4kIr9cPJnunClrytdEyqYAGodKRuJp1vTJ4UxN/
 1BnTe6yhCIqsmBtNGDIOiZ9MX3RH7nKUHwcoUfVbPJs6bGkQArd0EMsHSEgjTp5V
 MRDGSY=
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=H522PgMspmd9GHaJ8O2jbDyNrus=; b=rPatO
 hbMys5cPKt7cjCc7tOn7WkB0xhKVgdA8LXUeja2gWX2UClLJJg5xdx2FQqPQic1+
 8kSSwqlfDYA+ty5cuweu3yYExJOgmGmCsB1zmSrVDrub71qMbpRcMNRzhQd6974z
 Zvbkxob6gxYPY4jszBWylxRBd5h1lnsyh+L0mM=
X-Sasl-enc: wN0o4208qumU2lP6pPhx7SWPcnH7RRgmpFJWuPVmY0HK 1443168806
Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com
 [50.1.153.216])
 by mail.messagingengine.com (Postfix) with ESMTPA id AD6306800E8;
 Fri, 25 Sep 2015 04:13:26 -0400 (EDT)
Received: from ip6-localhost ([::1] helo=shorty)
 by shorty.local with esmtp (Exim 4.84)
 (envelope-from <dima@HIDDEN>)
 id 1ZfO83-0004jb-CJ; Fri, 25 Sep 2015 01:13:15 -0700
References: <87d1x7e53b.fsf@HIDDEN> <83k2rfhu93.fsf@HIDDEN>
From: Dima Kogan <dima@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <83k2rfhu93.fsf@HIDDEN>
Date: Fri, 25 Sep 2015 01:13:15 -0700
Message-ID: <871tdmex2c.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21556
Cc: 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Dima Kogan <dima@HIDDEN>
>> Date: Thu, 24 Sep 2015 17:05:12 -0700
>> 
>> Main question of this bug report so far:
>> 
>>   Is there a way to put a watchpoint on a lisp object?
>
> Theoretically, yes.

Hi. I just came back to this, figured out how to (semi-manually) put in
a watchpoint, and this watchpoint told me what's resetting the font
cache: the garbage collector. The backtrace in question:

    0x00000000005d2172 in compact_font_cache_entry (entry=24121763) at alloc.c:5313
    #0  0x00000000005d2172 in compact_font_cache_entry (entry=24121763) at alloc.c:5313
    #1  0x00000000005d221b in compact_font_caches () at alloc.c:5339
    #2  0x00000000005d2742 in garbage_collect_1 (end=0x7ffcdb166830) at alloc.c:5515
    #3  0x00000000005d2e1d in Fgarbage_collect () at alloc.c:5720
    #4  0x000000000054eb21 in maybe_gc () at lisp.h:4515
    #5  0x00000000005f638c in Ffuncall (nargs=3, args=0x7ffcdb166988) at eval.c:2584

    Lisp Backtrace:
    "Automatic GC" (0x0)
    "map-keymap" (0xdb166990)
    "keymap-canonicalize" (0xdb166f38)
    "x-create-frame" (0xdb1678a0)
    "x-create-frame-with-faces" (0xdb167dd8)
    0x12b9d80 PVEC_COMPILED
    "apply" (0xdb168450)
    "frame-creation-function" (0xdb1689f0)
    "make-frame" (0xdb168f40)
    "make-frame-on-display" (0xdb1694a8)
    "server-create-window-system-frame" (0xdb169a78)
    "server-process-filter" (0xdb169ff8)
    Hardware watchpoint 24: ((struct Lisp_Cons *) 0x1701190)->u.cdr


As a test I asked gdb to never drop fonts in the gc by acting as if
drop==0 in compact_font_cache_entry(), and that made the leak in this
bug go away. Clearly that's not a fix, but it's evidence that the
understanding of the problem is correct, so progress is being made.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 25 Sep 2015 06:57:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 25 02:57:05 2015
Received: from localhost ([127.0.0.1]:42420 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZfMwL-0000RY-61
	for submit <at> debbugs.gnu.org; Fri, 25 Sep 2015 02:57:05 -0400
Received: from out3-smtp.messagingengine.com ([66.111.4.27]:36913)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dima@HIDDEN>) id 1ZfMwI-0000RE-Kr
 for 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 02:57:03 -0400
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
 by mailout.nyi.internal (Postfix) with ESMTP id 1FBD22071E
 for <21556 <at> debbugs.gnu.org>; Fri, 25 Sep 2015 02:57:02 -0400 (EDT)
Received: from frontend2 ([10.202.2.161])
 by compute1.internal (MEProxy); Fri, 25 Sep 2015 02:57:02 -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=G9oWt
 0kuPnrbPd/dubGjkLD2paA=; b=BNdYT4WuOtuwUfrb3d+MzROUWA50nOEpAy2Fk
 OqXzopPNBfXOOgtIgCfLjsaurhGAAXgMioL+1z76CZy3an1bbh+JMyqSqfTEFY3u
 tTZJp4CwhYbCuB4sUYlpbFzpwTpQkWgoqwI0xmpr/tUFOuAEynpewWcGDnqngBkW
 3I2YDI=
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=G9oWt0kuPnrbPd/dubGjkLD2paA=; b=UD1Lp
 KZ0wxvH50ge7GRM6jFrr5RxGOK2wRhbHqQTRehtY+kUEohbm9Qme+X+vHKAAzNeK
 8y0fhFHurCwxsr7Vf3tmkwPWzgBsWEFXXCixuGOc9c1RVk4HCdaupHuS/hINf33s
 wdaEomDLKAa4CR0FhVTyMw8EFr/kOFxaPskJiY=
X-Sasl-enc: QPzLHsyp6qMSV9yeOVrJmFsYrRfZsqX5sAhNnzFc6ykQ 1443164221
Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com
 [50.1.153.216])
 by mail.messagingengine.com (Postfix) with ESMTPA id C8E71680088;
 Fri, 25 Sep 2015 02:57:01 -0400 (EDT)
Received: from ip6-localhost ([::1] helo=shorty)
 by shorty.local with esmtp (Exim 4.84)
 (envelope-from <dima@HIDDEN>)
 id 1ZfMwG-0002WE-MU; Thu, 24 Sep 2015 23:57:00 -0700
References: <87d1x7e53b.fsf@HIDDEN> <83k2rfhu93.fsf@HIDDEN>
From: Dima Kogan <dima@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <83k2rfhu93.fsf@HIDDEN>
Date: Thu, 24 Sep 2015 23:57:00 -0700
Message-ID: <8737y3dm0z.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 21556
Cc: 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

>> Is there a way to put a watchpoint on a lisp object? How?
>
> Depends on the object.  Which object do you want to put the watchpoint
> on?  Please show its source variable name and the source file lines
> where it is used.  Also, if the object is complex, what kinds of
> changes in it would you like to watch?

The object is the emacs font cache. Specifically in this case (Debian,
X11, xft fonts, lucid widgets) it is

  frame->output_data.x->display_info->name_list_element

where frame is a struct frame*, such as the first argument of

  font_load_for_lface()

In the original message for this bug report I showed 'pp' output for
this first argument of font_load_for_lface(). This function is called 4
times during the creation of one frame. I want to know why the font
cache is cleared before the 3rd call. I tried to examine the code, and
to place breakpoints in places that could be performing this cache
clear, but none of those places look like the right ones. If a
watchpoint is possible, it would tell me where this is cleared, instead
of me having to guess.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at 21556 <at> debbugs.gnu.org:


Received: (at 21556) by debbugs.gnu.org; 25 Sep 2015 06:45:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 25 02:45:46 2015
Received: from localhost ([127.0.0.1]:42408 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZfMlN-0000AQ-GS
	for submit <at> debbugs.gnu.org; Fri, 25 Sep 2015 02:45:45 -0400
Received: from mtaout21.012.net.il ([80.179.55.169]:64039)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <eliz@HIDDEN>) id 1ZfMlK-0000AG-2v
 for 21556 <at> debbugs.gnu.org; Fri, 25 Sep 2015 02:45:43 -0400
Received: from conversion-daemon.a-mtaout21.012.net.il by
 a-mtaout21.012.net.il (HyperSendmail v2007.08) id
 <0NV700900ZTF5A00@HIDDEN> for 21556 <at> debbugs.gnu.org;
 Fri, 25 Sep 2015 09:45:40 +0300 (IDT)
Received: from HOME-C4E4A596F7 ([84.94.185.246]) by a-mtaout21.012.net.il
 (HyperSendmail v2007.08) with ESMTPA id
 <0NV8009C60442B80@HIDDEN>;
 Fri, 25 Sep 2015 09:45:40 +0300 (IDT)
Date: Fri, 25 Sep 2015 09:45:44 +0300
From: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font)
In-reply-to: <87d1x7e53b.fsf@HIDDEN>
X-012-Sender: halo1@HIDDEN
To: Dima Kogan <dima@HIDDEN>
Message-id: <83k2rfhu93.fsf@HIDDEN>
References: <87d1x7e53b.fsf@HIDDEN>
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 21556
Cc: 21556 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: Eli Zaretskii <eliz@HIDDEN>
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

> From: Dima Kogan <dima@HIDDEN>
> Date: Thu, 24 Sep 2015 17:05:12 -0700
> 
> Main question of this bug report so far:
> 
>   Is there a way to put a watchpoint on a lisp object?

Theoretically, yes.

> How?

Depends on the object.  Which object do you want to put the watchpoint
on?  Please show its source variable name and the source file lines
where it is used.  Also, if the object is complex, what kinds of
changes in it would you like to watch?

> I'm observing that most (but not all) of the time, the menu font is
> being created around the same time as the cache reset. Backtrace:
> 
> 	    7fcf06d1e99f XftFontOpenName (/usr/lib/x86_64-linux-gnu/libXft.so.2.3.2)
> 	          6b5861 openXftFont (/tmp/emacs-tst)
> 	          6b5999 XlwMenuInitialize (/tmp/emacs-tst)
> 	    7fcf07ac9e2c [unknown] (/usr/lib/x86_64-linux-gnu/libXt.so.6.0.0)
> 	    7fcf07aca7c8 [unknown] (/usr/lib/x86_64-linux-gnu/libXt.so.6.0.0)
> 	    7fcf07acac18 _XtCreateWidget (/usr/lib/x86_64-linux-gnu/libXt.so.6.0.0)
> 	    7fcf07acaefd XtCreateWidget (/usr/lib/x86_64-linux-gnu/libXt.so.6.0.0)
> 	          6b01f3 xlw_create_menubar (/tmp/emacs-tst)
> 	          6af1d3 instantiate_widget_instance (/tmp/emacs-tst)
> 	          6ae462 allocate_widget_instance (/tmp/emacs-tst)
> 	          6af306 lw_make_widget (/tmp/emacs-tst)
> 	          6af392 lw_create_widget (/tmp/emacs-tst)
> 	          4974b9 set_frame_menubar (/tmp/emacs-tst)
> 	          497673 initialize_frame_menubar (/tmp/emacs-tst)
> 	          5358f5 Fx_create_frame (/tmp/emacs-tst)
> 
> This font allocation doesn't read or write to the frame cache, and has
> its own font-cleanup call that appears to work. I cannot find any
> explicit evidence that this clears out the font cache, but turning off
> the menu with M-x menu-bar-mode makes this leak mostly go away.

This is in the lwlib library, whose font allocations are AFAIK not
tracked by Emacs's font managing machinery.  With other toolkits, we
don't even know which fonts are used by the menus, and don't handle
nor have access to those fonts.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 25 Sep 2015 00:05:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 24 20:05:29 2015
Received: from localhost ([127.0.0.1]:42283 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ZfGW0-0007hT-GN
	for submit <at> debbugs.gnu.org; Thu, 24 Sep 2015 20:05:29 -0400
Received: from eggs.gnu.org ([208.118.235.92]:51732)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <dima@HIDDEN>) id 1ZfGVv-0007hI-IB
 for submit <at> debbugs.gnu.org; Thu, 24 Sep 2015 20:05:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <dima@HIDDEN>) id 1ZfGVu-000340-2d
 for submit <at> debbugs.gnu.org; Thu, 24 Sep 2015 20:05:23 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:37218)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <dima@HIDDEN>) id 1ZfGVu-00033l-06
 for submit <at> debbugs.gnu.org; Thu, 24 Sep 2015 20:05:22 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33503)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <dima@HIDDEN>) id 1ZfGVs-0006pH-Le
 for bug-gnu-emacs@HIDDEN; Thu, 24 Sep 2015 20:05:21 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <dima@HIDDEN>) id 1ZfGVp-00031e-Ef
 for bug-gnu-emacs@HIDDEN; Thu, 24 Sep 2015 20:05:20 -0400
Received: from out2-smtp.messagingengine.com ([66.111.4.26]:40307)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <dima@HIDDEN>) id 1ZfGVp-000310-8u
 for bug-gnu-emacs@HIDDEN; Thu, 24 Sep 2015 20:05:17 -0400
Received: from compute5.internal (compute5.nyi.internal [10.202.2.45])
 by mailout.nyi.internal (Postfix) with ESMTP id 0808F22F96
 for <bug-gnu-emacs@HIDDEN>; Thu, 24 Sep 2015 20:05:14 -0400 (EDT)
Received: from frontend2 ([10.202.2.161])
 by compute5.internal (MEProxy); Thu, 24 Sep 2015 20:05:14 -0400
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net;
 h=content-type:date:from:message-id:mime-version:subject:to
 :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=eeZ0j5uBIBcP9sdevpAmaWfIpZk
 =; b=Nnxexpp6wde/Kg+pUo1t7GcRdUmSrk09WTSFZhMtNWAAdu1zLU+e7tRY6m3
 +HDhKRsCz27/9s14F9qe0HezpMIErUsRhwDGfsMb1pPiHPporF5pbKv8BkZKq1+Q
 RQuL3WSIn2EWMrJOmwzcHIKdZKSlsRfk67QC8kSFGBU549Sc=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=
 messagingengine.com; h=content-type:date:from:message-id
 :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=ee
 Z0j5uBIBcP9sdevpAmaWfIpZk=; b=DyB0qrBCvoVOOlAbk9gLIvn6EuPA9pFs7/
 VP7lkvW8uj9Wn8a9u0YeZA4Y7qX3t+KDFvkqgWpfXJtdrsf+jwpRvfEnJlG/NIjo
 1gkfsAVpf6DE58EKPhfz8Cej6u7HM/4OU3cRLEzi0o7PdFNoX8n9K1VRnlv2R8Dk
 Nv1aQTis0=
X-Sasl-enc: PdeqAhZWLU4RyqNM9zhrerOO8F39QneHqLmzPcbAh/SY 1443139513
Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com
 [50.1.153.216])
 by mail.messagingengine.com (Postfix) with ESMTPA id AD7216800A5
 for <bug-gnu-emacs@HIDDEN>; Thu, 24 Sep 2015 20:05:13 -0400 (EDT)
Received: from ip6-localhost ([::1] helo=shorty)
 by shorty.local with esmtp (Exim 4.84)
 (envelope-from <dima@HIDDEN>) id 1ZfGVk-0006Vw-Jc
 for bug-gnu-emacs@HIDDEN; Thu, 24 Sep 2015 17:05:12 -0700
From: Dima Kogan <dima@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 25.0.50; Memory leak in emacs -Q with lucid (font)
Date: Thu, 24 Sep 2015 17:05:12 -0700
Message-ID: <87d1x7e53b.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

Hi. This is similar to, but different from
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21509

On my machine if I open a daemon with emacs -Q, and start/stop clients
as described in the previous report, I see one font leaking with every
frame. With one exception (below), everything that is cleaned out, is
cleaned with x_delete_terminal() where all fonts in emacs's font cache
are cleared.

The bug appears to be that something is resetting emacs's font cache at
some point during frame creation, and any fonts that were cached before
that point end up leaking. With a breakpoint at font_load_for_lface() I
print the font cache. font_load_for_lface() is called 4 times during
frame creation, and the caches look like this:


(":0.0" (x 1) (xft 1))
(":0.0" (x 1)
  (xft 1
    (#<font-spec xft nil Monospace nil iso8859-1 nil nil nil nil nil nil nil ((:name . "monospace-10"))> .
      [#<font-entity xft unknown DejaVu\ Sans\ Mono nil iso10646-1 bold oblique normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/dejavu/DejaVuSansMono-BoldOblique.ttf" . 0) (:name . "monospace-10"))>
       #<font-entity xft unknown DejaVu\ Sans\ Mono nil iso10646-1 bold normal normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf" . 0) (:name . "monospace-10"))>
       #<font-entity xft unknown DejaVu\ Sans\ Mono nil iso10646-1 normal normal normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf" . 0) (:name . "monospace-10"))>
       #<font-entity xft unknown DejaVu\ Sans\ Mono nil iso10646-1 normal oblique normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Oblique.ttf" . 0) (:name . "monospace-10"))>])))
(":0.0" (x 1) (xft 1))
(":0.0" (x 1)
  (xft 1
    (#<font-spec xft unknown DejaVu\ Sans\ Mono nil iso8859-1 nil nil nil nil nil nil nil nil> .
      [#<font-entity xft unknown DejaVu\ Sans\ Mono nil iso10646-1 bold oblique normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/dejavu/DejaVuSansMono-BoldOblique.ttf" . 0))>
       #<font-entity xft unknown DejaVu\ Sans\ Mono nil iso10646-1 bold normal normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf" . 0))>
       #<font-entity xft unknown DejaVu\ Sans\ Mono nil iso10646-1 normal normal normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf" . 0))>
       #<font-entity xft unknown DejaVu\ Sans\ Mono nil iso10646-1 normal oblique normal 0 nil 100 0 ((:font-entity "/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Oblique.ttf" . 0))>])))


Note that this cache is reset between the 2nd and 3rd calls without the
corresponding font being freed. I cannot tell where this is being
cleared; all the suspect breakpoints aren't hitting. Main question of
this bug report so far:




  Is there a way to put a watchpoint on a lisp object? How?




I'm observing that most (but not all) of the time, the menu font is
being created around the same time as the cache reset. Backtrace:

	    7fcf06d1e99f XftFontOpenName (/usr/lib/x86_64-linux-gnu/libXft.so.2.3.2)
	          6b5861 openXftFont (/tmp/emacs-tst)
	          6b5999 XlwMenuInitialize (/tmp/emacs-tst)
	    7fcf07ac9e2c [unknown] (/usr/lib/x86_64-linux-gnu/libXt.so.6.0.0)
	    7fcf07aca7c8 [unknown] (/usr/lib/x86_64-linux-gnu/libXt.so.6.0.0)
	    7fcf07acac18 _XtCreateWidget (/usr/lib/x86_64-linux-gnu/libXt.so.6.0.0)
	    7fcf07acaefd XtCreateWidget (/usr/lib/x86_64-linux-gnu/libXt.so.6.0.0)
	          6b01f3 xlw_create_menubar (/tmp/emacs-tst)
	          6af1d3 instantiate_widget_instance (/tmp/emacs-tst)
	          6ae462 allocate_widget_instance (/tmp/emacs-tst)
	          6af306 lw_make_widget (/tmp/emacs-tst)
	          6af392 lw_create_widget (/tmp/emacs-tst)
	          4974b9 set_frame_menubar (/tmp/emacs-tst)
	          497673 initialize_frame_menubar (/tmp/emacs-tst)
	          5358f5 Fx_create_frame (/tmp/emacs-tst)

This font allocation doesn't read or write to the frame cache, and has
its own font-cleanup call that appears to work. I cannot find any
explicit evidence that this clears out the font cache, but turning off
the menu with M-x menu-bar-mode makes this leak mostly go away.




Acknowledgement sent to Dima Kogan <dima@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#21556; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 29 Oct 2015 23:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.