From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: using finalizers Date: Fri, 31 Dec 2021 11:21:04 -0500 Message-ID: References: <878rw1pvcw.fsf@logand.com> <83r19tgqlq.fsf@gnu.org> <87v8z5nmsp.fsf@logand.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23395"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Rudolf Schlatte Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 31 17:21:55 2021 Return-path: Envelope-to: ged-emacs-devel@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 1n3KfC-0005rn-Hc for ged-emacs-devel@m.gmane-mx.org; Fri, 31 Dec 2021 17:21:54 +0100 Original-Received: from localhost ([::1]:47930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3KfA-0004hs-Tj for ged-emacs-devel@m.gmane-mx.org; Fri, 31 Dec 2021 11:21:52 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3KeV-0003vn-LI for emacs-devel@gnu.org; Fri, 31 Dec 2021 11:21:12 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:48735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3KeT-0003gV-5r for emacs-devel@gnu.org; Fri, 31 Dec 2021 11:21:10 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id CAD3F442B6E; Fri, 31 Dec 2021 11:21:07 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 75503442B6B; Fri, 31 Dec 2021 11:21:06 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1640967666; bh=Bf4c6OPxYgayF44OP3x7GjbWW7mdEPTx9xcn0+rp3no=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=bRMxi/5WW9rBzdGCByqsoAgV80tGaaITi4r4534Khace+e+hj/y+6ZVuylr9Kgdeo onJQmIYZxx71iWlbdXPGEOXlqzvm+OnPNuvwA2aHthuWimr7cgGElsByH8imdgThlU k3N4gpj3yuye5Xe8+boNXEiajdDsW+njx6k1BNT+iawB5vZyYYLOA9fiUKc1VYRfIy hLiRqi38CG1Q8qU8AbqtlS/2YXPe2XyuOECRcGKtigBwoPHGWZPARE/zIoGfxlvu5a Dk95RKSuFpWEqmOlC9b1RzqZylc2LI46jLFbagMkY6lDvMVeYXgv7fjwaHHQJ1KkM3 tbS5TpnHzvzpw== Original-Received: from pastel (unknown [216.154.30.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 38DCF120205; Fri, 31 Dec 2021 11:21:06 -0500 (EST) In-Reply-To: (Rudolf Schlatte's message of "Fri, 31 Dec 2021 15:23:32 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:283750 Archived-At: Rudolf Schlatte [2021-12-31 15:23:32] wrote: > Tomas Hlavaty writes: >> >> I can see these cases where garbage collection might not do its job: >> >> 1. imprecise gc >> >> 2. program exit or abort >> >> 3. a leak to be fixed > > 4. the gc is generational and the object is in an old generation > > 5. the gc is incremental and didn't get around to the object yet > > ... etc > > I'm sure you knew this already, but in general, using gc for non-memory > resource management (e.g., "please close this file when this Lisp object > is GCed") is not a good idea--depending on the GC behavior, you'll run > out of file handles or whatnot. The RAII pattern in C++ > deterministically calls a destructor when a stack-allocated object goes > out of scope; in Lisp, the various `with-foo' macros serve the same > purpose. But the context here is a "bug report" about a finalizer not being called and it seemed pretty clear that the call to `garbage-collect` was just there to try and make the bug more apparent, not because the real ELisp code relies on the finalizer being called right at the first call to `garbage-collect` after the object became unreachable. Stefan