From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#56623: memory leak introduced by new nonrecursive lisp reader Date: Sat, 27 Aug 2022 17:35:37 +0200 Message-ID: <8735dh7l86.fsf@gnus.org> References: <7DC3EB6A-097E-46F1-806E-33C02F01EA47@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18392"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Tom Gillespie , 56623@debbugs.gnu.org, greghendershott@gmail.com To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 27 17:36:11 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 1oRxr0-0004Wq-Nf for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Aug 2022 17:36:10 +0200 Original-Received: from localhost ([::1]:60718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRxqy-0005PT-Rz for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Aug 2022 11:36:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRxqs-0005Ox-Dw for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 11:36:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38847) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRxqs-0006MK-4v for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 11:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oRxqs-0000zi-0e for bug-gnu-emacs@gnu.org; Sat, 27 Aug 2022 11:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Aug 2022 15:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56623 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 56623-submit@debbugs.gnu.org id=B56623.16616145493800 (code B ref 56623); Sat, 27 Aug 2022 15:36:01 +0000 Original-Received: (at 56623) by debbugs.gnu.org; 27 Aug 2022 15:35:49 +0000 Original-Received: from localhost ([127.0.0.1]:56829 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oRxqe-0000zE-Jh for submit@debbugs.gnu.org; Sat, 27 Aug 2022 11:35:48 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:56150) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oRxqc-0000yy-HX for 56623@debbugs.gnu.org; Sat, 27 Aug 2022 11:35:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :Date:References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=+qFwxKNTyS7LMyQU5XanKhOfUvw6YdkFfmacVwA7n7M=; b=fxqr7JpQ5jt3BFD53m8eJrqnEy 8NIaqpGAWimg/QuzlEV83VBKDVAVy6tGRId3GJh/2A1wtxLOAfkTJg3o+9GqWwnwB/qX0q9H8OR/3 dpwaQN0IkFYArzsHC9/X4IB99FtXoKoZdxcA5YEH68Qu50RIm4AYOoLovIp62RWMc6N4=; Original-Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oRxqT-0003rr-UI; Sat, 27 Aug 2022 17:35:40 +0200 In-Reply-To: <7DC3EB6A-097E-46F1-806E-33C02F01EA47@acm.org> ("Mattias =?UTF-8?Q?Engdeg=C3=A5rd?="'s message of "Wed, 27 Jul 2022 11:20:11 +0200") X-Now-Playing: Fire!'s _Defeat_: "A random belt, rats your out" 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:240943 Archived-At: Mattias Engdeg=C3=A5rd writes: > A counter-argument is that these undead objects will only be kept artific= ially alive as long as GC only takes place in the reader. Anyway, the hunch= is easily tested: try either or both of these changes: > > 1. reduce stackbufsize: > > --- a/src/lread.c > +++ b/src/lread.c > @@ -2919,7 +2919,7 @@ digit_to_number (int character, int base) > /* Size of the fixed-size buffer used during reading. > It should be at least big enough for `invalid_radix_integer' but > can usefully be much bigger than that. */ > -enum { stackbufsize =3D 1024 }; > +enum { stackbufsize =3D 64 }; > > static void > invalid_radix_integer (EMACS_INT radix, char stackbuf[VLA_ELEMS (stackbu= fsize)], > > 2. zero the buffer on entry: > > --- a/src/lread.c > +++ b/src/lread.c > @@ -3678,6 +3678,7 @@ read_stack_push (struct read_stack_entry e) > read0 (Lisp_Object readcharfun, bool locate_syms) > { > char stackbuf[stackbufsize]; > + memset (stackbuf, 0, stackbufsize); > char *read_buffer =3D stackbuf; > ptrdiff_t read_buffer_size =3D sizeof stackbuf; > char *heapbuf =3D NULL; > > If either makes things better, maybe we can come up with a solution that = doesn't hurt performance. This was a month ago -- Tom, did you try these changes?