From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxime Devos Newsgroups: gmane.lisp.guile.devel Subject: Re: GC + Java finalization Date: Fri, 19 Nov 2021 13:53:02 +0000 Message-ID: References: <9ce77d5e08d50456eddc575179b68ac17afc9bf6.camel@hahnjo.de> <1cc3648e5196bf23023ec7a0ab95a9ad46f8554c.camel@telenet.be> <21fe294b75b001afbd1be0e972a19ddb7187e98b.camel@hahnjo.de> <43a9f555dec7ddeee1ad34c278042a6bad6c59ec.camel@telenet.be> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25334"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.38.3-1 To: Jonas Hahnfeld , guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Fri Nov 19 15:10:42 2021 Return-path: Envelope-to: guile-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 1mo4bA-0006Jh-L8 for guile-devel@m.gmane-mx.org; Fri, 19 Nov 2021 15:10:40 +0100 Original-Received: from localhost ([::1]:43280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mo4b9-0003Mz-Ll for guile-devel@m.gmane-mx.org; Fri, 19 Nov 2021 09:10:39 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mo4KI-0001QD-5K for guile-devel@gnu.org; Fri, 19 Nov 2021 08:53:22 -0500 Original-Received: from [2a02:1800:120:4::f00:15] (port=59348 helo=andre.telenet-ops.be) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mo4KD-0001SY-3C for guile-devel@gnu.org; Fri, 19 Nov 2021 08:53:13 -0500 Original-Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by andre.telenet-ops.be with bizsmtp id LDt22600Q4UW6Th01Dt2dy; Fri, 19 Nov 2021 14:53:02 +0100 In-Reply-To: <43a9f555dec7ddeee1ad34c278042a6bad6c59ec.camel@telenet.be> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1637329982; bh=2Fd8U0A9Ke6RnTQ2AyZrv0PvqT8478R50M/mbniTn9k=; h=Subject:From:To:Date:In-Reply-To:References; b=NgMCerLXTPtvRmKb7aMXjZA8p4BL6U7lEZDf3Mjmvo90RFSaWJndkZJFWD2xm0ruM NyricvqBEpgmHiM1BHChCN1+ZvriWa9lLFxuld/hsdKZL5Uro09XRf6OdzSN18FvOf YTmLknQMRwL5SXkI4RSCVADgGW6X1DXhL9pOCdagOB3DChx1luE8Hh6wd9IEFZkFwk dBeiXGFItlT+/EU3jxniT6Tr+Zf1UXn6MtH0ywQpsh+RGxpV354FBgSswvaaFvHLQE nZ/uOJIU0XvC9+dcRz+QlrzcHgre9bKCKT/XBrXAjmGPTDarnp91uOtuBQliYnOjF8 EEbbd212Kzi0A== X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a02:1800:120:4::f00:15 (failed) Received-SPF: pass client-ip=2a02:1800:120:4::f00:15; envelope-from=maximedevos@telenet.be; helo=andre.telenet-ops.be X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 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_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20967 Archived-At: Maxime Devos schreef op vr 19-11-2021 om 13:44 [+0000]: > Jonas Hahnfeld schreef op vr 19-11-2021 om 14:40 [+0100]: > > Am Freitag, dem 19.11.2021 um 13:35 +0000 schrieb Maxime Devos: > > > Jonas Hahnfeld schreef op vr 19-11-2021 om 14:32 [+0100]: > > > > > You coud simply ... > > > > > > > > > > > > > > > > -      scm_gc_free (rx, sizeof(regex_t), "regex"); > > > > > > +      free (rx); > > > > > > > > > > drop the scm_gc_free AFAIK. > > > > > > > > No, I cannot as explained in the patch summary: If we use > > > > scm_gc_free > > > > in a free function of a Smob, this relies on Java finalization > > > > because > > > > the memory must not be reclaimed in the same cycle. > > > > > > The suggestion was to remove scm_gc_free, and not introduce free. > > > I.e., don't free rx manually at all, let boehmgc decide: > > > > > >  regex_free (SCM obj) > > >  { > > >    regfree (SCM_RGX (obj)); > > > -  scm_gc_free (SCM_RGX (obj), sizeof(regex_t), "regex"); > > >    return 0; > > >  } > > > > This is dangerous because we still pass the memory to regfree, so > > it > > must not be freed before. > > How can removing a call to a free function introduce new use-after- > free > bugs or double-free bugs? AFAIK, ignoring memory leak concerns (which > don't seem to apply here because of boehmgc), freeing less stuff > cannot > introduce new bugs. Unless scm_gc_free is called to act as scm_remember_upto_here, such that the memory regex_t isn't freed until regfree has done what it should? But regfree is called with the regex_t, so scm_remember_upto_here wouldn't be needed. Unless it actually is because of how finalisation in boehmgc interacts with how boehmgc keeps track of what can be collected and what not (I don't know the details). Greetings, Maxime.