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 14:21:08 +0000 Message-ID: References: <9ce77d5e08d50456eddc575179b68ac17afc9bf6.camel@hahnjo.de> <89404d642bd0225001e78d331c88849f67da5254.camel@hahnjo.de> 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="4000"; 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:21:33 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 1mo4lg-0000oH-1g for guile-devel@m.gmane-mx.org; Fri, 19 Nov 2021 15:21:32 +0100 Original-Received: from localhost ([::1]:34570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mo4le-0000EX-FN for guile-devel@m.gmane-mx.org; Fri, 19 Nov 2021 09:21:30 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mo4lT-0000Dq-6B for guile-devel@gnu.org; Fri, 19 Nov 2021 09:21:19 -0500 Original-Received: from [2a02:1800:110:4::f00:1a] (port=47700 helo=albert.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 1mo4lL-0002ec-Tq for guile-devel@gnu.org; Fri, 19 Nov 2021 09:21:18 -0500 Original-Received: from ptr-bvsjgyhxw7psv60dyze.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:3c5f:2eff:feb0:ba5a]) by albert.telenet-ops.be with bizsmtp id LEM82600a4UW6Th06EM8Eg; Fri, 19 Nov 2021 15:21:09 +0100 In-Reply-To: <89404d642bd0225001e78d331c88849f67da5254.camel@hahnjo.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1637331669; bh=y0V+cuQCB6WEPRRHZlyUhB7kUATGs5jvSHBU8JjlAb8=; h=Subject:From:To:Date:In-Reply-To:References; b=TQLPN4NfzTIh1WZ+eFwyLBJA4DbC2hxuu2Y5WQ7yD3wUTTnkWjLoAcOL1tW6cCPbs UH/JMh3jSTh2Ne0r5HQIDArzs6vWkf/GlOmvY9/S1SnFziJOxORMLyPvIgtZFfPa3U lpjzh0T7JRTF19xIGIfCd5454CLoukAu+HJ5N61JXjeWIV1dmGNmodZDRfvxF7/qKO t5k5qRakR2OcHMW0RxV2k3Dy+Ye0bmYUKwu4xn3AkwF20STvOsVk1pwi1SrKIj977w vssp++ifzTOGmTkh+xN/rfJZUyitXmlJvkuxTOr23DHqOwOnmj8hJ1+1FdF5OhXAcT Rqga4eA8/bcfQ== X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a02:1800:110:4::f00:1a (failed) Received-SPF: pass client-ip=2a02:1800:110:4::f00:1a; envelope-from=maximedevos@telenet.be; helo=albert.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:20971 Archived-At: Jonas Hahnfeld schreef op vr 19-11-2021 om 14:35 [+0100]: > Am Freitag, dem 19.11.2021 um 13:15 +0000 schrieb Maxime Devos: > > Jonas Hahnfeld schreef op do 15-07-2021 om 20:44 [+0200]: > > > +  SCM *smobs = scm_gc_malloc (sizeof(SCM) * SMOBS_COUNT, > > > "smobs"); > > > + > > >    int i; > > >    mark_call_count = 0; > > >    for (i = 0; i < SMOBS_COUNT; i++) > > > -    make_x (); > > > +    smobs[i] = make_x (); > > >    scm_gc (); > > > > smobs doesn't need to be protected for the whole function call, > > until after the scm_gc() should be sufficient I think. > > That's what the patch does, no? For reference, the whole function > (after this patch) looks like: > > SCM *smobs = scm_gc_malloc (sizeof(SCM) * SMOBS_COUNT, "smobs"); > > int i; > mark_call_count = 0; > for (i = 0; i < SMOBS_COUNT; i++) >   smobs[i] = make_x (); > scm_gc (); > if (mark_call_count < SMOBS_COUNT) >   {   >     fprintf (stderr, "FAIL: SMOB mark function called for each > SMOB\n"); >     exit (EXIT_FAILURE); >   }   > scm_remember_upto_here_1 (smobs); > > While we could move the remember_upto_here immediately after the call > to scm_gc(), the current version ensures that the memory is still > available when the error is checked. The error checking code (I'm thinking of the if (mark_call_count ...) fprintf(...) exit(...) here) isn't using 'smobs', so the error checking code doesn't need the memory to be available AFAIK. Greetings, Maxime Devos.