From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Antipov Newsgroups: gmane.emacs.bugs Subject: bug#21556: 25.0.50; Memory leak in emacs -Q with lucid (font) Date: Wed, 30 Sep 2015 13:16:48 +0300 Message-ID: <560BB690.3020804@yandex.ru> References: <87zj082t34.fsf@gnu.org> <83io6wffm9.fsf@gnu.org> <87lhbqdhjp.fsf@secretsauce.net> <83d1x2eugp.fsf@gnu.org> <87oagl376v.fsf@secretsauce.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1443681083 31434 80.91.229.3 (1 Oct 2015 06:31:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 Oct 2015 06:31:23 +0000 (UTC) Cc: 21556@debbugs.gnu.org To: Dima Kogan , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 01 08:31:13 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZhXOZ-0008G6-6i for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Oct 2015 08:31:11 +0200 Original-Received: from localhost ([::1]:38565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhXOY-0001LW-Gs for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Oct 2015 02:31:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhERb-0005h3-EZ for bug-gnu-emacs@gnu.org; Wed, 30 Sep 2015 06:17:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhERa-0008MF-Hx for bug-gnu-emacs@gnu.org; Wed, 30 Sep 2015 06:17:03 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhERa-0008MB-FI for bug-gnu-emacs@gnu.org; Wed, 30 Sep 2015 06:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZhERZ-0004eq-MQ for bug-gnu-emacs@gnu.org; Wed, 30 Sep 2015 06:17:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Antipov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Sep 2015 10:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21556 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21556-submit@debbugs.gnu.org id=B21556.144360821517887 (code B ref 21556); Wed, 30 Sep 2015 10:17:01 +0000 Original-Received: (at 21556) by debbugs.gnu.org; 30 Sep 2015 10:16:55 +0000 Original-Received: from localhost ([127.0.0.1]:48700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZhERT-0004eR-0r for submit@debbugs.gnu.org; Wed, 30 Sep 2015 06:16:55 -0400 Original-Received: from forward16h.cmail.yandex.net ([87.250.230.158]:45778) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZhERQ-0004eI-My for 21556@debbugs.gnu.org; Wed, 30 Sep 2015 06:16:54 -0400 Original-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) Original-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) Original-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 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 In-Reply-To: <87oagl376v.fsf@secretsauce.net> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:107093 Archived-At: 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