From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel =?UTF-8?Q?Mart=C3=ADn?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#56462: 29.0.50; [PATCH] Memory leak in ns_draw_relief Date: Sat, 09 Jul 2022 16:13:39 +0200 Message-ID: References: Reply-To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18761"; mail-complaints-to="usenet@ciao.gmane.io" To: 56462@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 09 16:14:20 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oABDw-0004hw-0r for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Jul 2022 16:14:20 +0200 Original-Received: from localhost ([::1]:50528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oABDu-0007yE-JA for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 09 Jul 2022 10:14:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oABDe-0007r7-Ha for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2022 10:14:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41774) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oABDe-00088J-8m for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2022 10:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oABDe-0000vT-3N for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2022 10:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Jul 2022 14:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56462 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16573760303530 (code B ref -1); Sat, 09 Jul 2022 14:14:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Jul 2022 14:13:50 +0000 Original-Received: from localhost ([127.0.0.1]:35671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oABDR-0000us-P6 for submit@debbugs.gnu.org; Sat, 09 Jul 2022 10:13:50 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:48158) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oABDQ-0000uj-2a for submit@debbugs.gnu.org; Sat, 09 Jul 2022 10:13:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oABDP-0007oz-U0 for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2022 10:13:47 -0400 Original-Received: from sonic305-20.consmr.mail.ir2.yahoo.com ([77.238.177.82]:44518) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oABDO-00087I-3M for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2022 10:13:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1657376022; bh=f1fPTntxucv/FD9HBM/VbX/fJ1KHUuMijQlILsqFj4c=; h=From:To:Subject:Date:References:From:Subject:Reply-To; b=LrbBKEfm+0AigJfjHH3GKb+xn9fvhVRodDh3dJwCWPiYDq7uNM07lzZqf1IzqpOgt0qG60QmKAnQ0wm/lFASau4Qm/8+47Sn49y7cw8dM5e4udx9UIMDETQnKpLL6kXuQSZjXXT0lM9laA7YQj+kxec4OkWtDuTq5AuaifG8Ip5pLe2nyDqoLYyQ1Rwx5L38DRTNt6uD8ENHocO4iRox+bOb/VrQDbMoStB392cyokSjpGXdCrqXo53jTGIQJ1qOfrB6L31dvyTp8t4wWtvKuvwgw4PcFbnmjInGtOdZJj4MFtAih3oMNJuxq56s/UFaPhKMNdwIH3rOWh9yBYLPvw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1657376022; bh=h2HAOPEC2SnJIJW/AXKpxPVy/QA9p2mZPuM4j9dcz0v=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=C++24Tkk1818noPpHkLltswKAocftuHn5kMhulk/bxsTz8kDpW0uxIRYg6RAsRDTgJKHXO197zekcXnESi0X2/ofUXuKsLOzjew86Mcb7ix4DPxAjzR3dgN3JBlLCPxHe6IQBTF6J1g6Ju7hVIJvQfW6Ab2vQ1eGMi7L+zgeGl2b6k7zxMh4NWLM2S1/bwQ+n/YU+kD+7li38lxEbhCk3CEP4FzlQoLs8QOfIEF3LshD1oXNP0KxTDfwQUtoRk5HGx3gDVjYYg7HNbEZr7pajIjdBFb3PD22yX1E5d+B183NCjEWn3IflsiVTex+UnXgIMLIP6sSGSjj3yXeGCSbIA== X-YMail-OSG: e9wEWNcVM1m_sErNAYwpaKUg5KgNGtT.A1lSmvDzFA.I1jqDu2f7feXBtUifYFW HYTeSHljZ4KOzKUhpK08EdzoExeMKGKa9M0vnpmrrDOCaD9jpKLj8cA9Qnpw7PXdQKAvfsde2B3A V8xuzQHIBVffQbjKPDy1yoxexPE0I1M5ytSYLnOKABor4aESUclqap_ILT7O54MtJgmjp4YITlkK 3gwtpxlDd5qx69K_uR9y8UtblOM1S81dPKuIA6viqYuCW5i_nTljGgWsnDx9KT_r.VG6VFj2I8k4 Gh0LWzB51UHv._WYJc8K6oybcZzu5fLM84dlzTpvFy.tKxd3nYhylQ98kftgK7U65C5nmR6lFMQY hlKSeAMZcldzdTW3.hbHF8l495vQpL1LADXiVFZ6295vbfWLxBJsJ5I9TUkpvaHrzuHoE7GDXEq5 1GavXxKakaanWxpz19QP6rH4lX3L5SQpxGW_.z6aIJ4zBzt6LhoutnrltHH9AaR_mejdQPkQC5_B G1yv5bvHSnT0IbRms7Ce6QGAO_as8lzm8jo3EX_6KtuwxQu.cgaOhdK5Me4RBm3rJjLQUwxj_pYM piDtTotPnOZCDMLR8M8okEX_PRWlvRfdoycT_HyEeC7C2qq9N_enfBiE941nhvUMvcqGiaOnAvGK zzH.3kX9RmQymoxlylbw9kCZN1cFJYMAFOM8aYWkg0y9lT12U3grR0beR_piElAgYHvktxzVH_1e w5.kgu0_MpSRkF6Jzu0LYdGKVUDkPf0Hn8DVCVd_5ct3.3AKDOw3LSdnaphkO0WxldmbKfW7lLCA pHL4zQxaHxY62wDeUkB1sIlBd5_vayhRdBXHcxYLq9 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.ir2.yahoo.com with HTTP; Sat, 9 Jul 2022 14:13:42 +0000 Original-Received: by hermes--canary-production-ir2-74b4d6d794-lc6zr (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 23047981090dd0634074fd1ae552ba00; Sat, 09 Jul 2022 14:13:40 +0000 (UTC) X-Mailer: WebService/1.1.20381 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=77.238.177.82; envelope-from=mardani29@yahoo.es; helo=sonic305-20.consmr.mail.ir2.yahoo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:236521 Archived-At: --=-=-= Content-Type: text/plain I ran the Leaks tool with Emacs 29, and I've found a memory leak in the NS version of Emacs. Since commit c7b48b61d08f0b6a08584080badc60fe62ba1db1, in function ns_draw_relief, static local variables baseCol and lightCol are assigned to nil separately to their declaration. That has the subtle consequence that the further down calls to [baseCol release] and [lightCol release] become a no-op, so each time ns_draw_relief is called it leaks some instances of NSColor. The fix is to revert to the previous way those static variables were declared. I've attached a patch with the correction. With this fix, the leaks tool doesn't report the NSColor leaks anymore when I play around with Emacs 29. Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-memory-leak-in-ns_draw_relief.patch >From acebb668e310da526f262f6a47090eddbb9c76a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Sat, 9 Jul 2022 15:54:07 +0200 Subject: [PATCH] Fix memory leak in ns_draw_relief * src/nsterm.m (ns_draw_relief): Assigning the static local variables baseCol and lightCol to nil leaks memory as of the second time ns_draw_relief is called, because the calls to [baseCol release] and [lightCol release] further down the function become a no-op. This bug was introduced in c7b48b61d08f0b6a08584080badc60fe62ba1db1. --- src/nsterm.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index 7f232e7292..dc55edf0eb 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3486,13 +3486,11 @@ larger if there are taller display elements (e.g., characters of some sides not being drawn, and because the rect will be filled. -------------------------------------------------------------------------- */ { - static NSColor *baseCol, *lightCol, *darkCol; + static NSColor *baseCol = nil, *lightCol = nil, *darkCol = nil; NSColor *newBaseCol; NSRect inner; NSBezierPath *p; - baseCol = nil; - lightCol = nil; newBaseCol = nil; p = nil; -- 2.34.1 --=-=-=--