From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jonas Hahnfeld via "Developers list for Guile, the GNU extensibility library" Newsgroups: gmane.lisp.guile.devel Subject: Re: GC + Java finalization Date: Fri, 19 Nov 2021 14:35:44 +0100 Message-ID: <89404d642bd0225001e78d331c88849f67da5254.camel@hahnjo.de> References: <9ce77d5e08d50456eddc575179b68ac17afc9bf6.camel@hahnjo.de> Reply-To: Jonas Hahnfeld Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-MhJcglaa3bpYFkAntlYR" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40503"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.42.1 To: Maxime Devos , guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Fri Nov 19 14:36:27 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 1mo440-000AED-Eb for guile-devel@m.gmane-mx.org; Fri, 19 Nov 2021 14:36:24 +0100 Original-Received: from localhost ([::1]:59102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mo43y-000624-RS for guile-devel@m.gmane-mx.org; Fri, 19 Nov 2021 08:36:23 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:56216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mo43T-0005zb-8k for guile-devel@gnu.org; Fri, 19 Nov 2021 08:35:52 -0500 Original-Received: from [2a03:4000:2a:2c1::1] (port=50884 helo=mail.hahnjo.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mo43R-0000dg-Hj for guile-devel@gnu.org; Fri, 19 Nov 2021 08:35:51 -0500 Original-Received: from [IPv6:2001:16b8:1e92:200:6657:51b0:48f8:9366] (unknown [IPv6:2001:16b8:1e92:200:6657:51b0:48f8:9366]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mail.hahnjo.de (Postfix) with ESMTPSA id 033715428919; Fri, 19 Nov 2021 14:35:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hahnjo.de; s=default; t=1637328945; bh=iSaNCYwN4g395L27Y7MILjJZO+MyXN3vXY7r5ZNuEhY=; h=Subject:From:To:Date:In-Reply-To:References; b=1Ph+0j4AKPwb9Br5YfoKqIZLM6KIYYsrwTNArooGIPougd9YQqFRVpfe0NTZxNPJ2 QvfDCfSK+MoGx+Al4+bmVYHAizepfikkzJ0BPc1Z75lT/VG37O97yEFpppGrFR6DeK jLrtQR6DRGIh1wvFJLZmJqwEItM6oVW0M2E8IMQlv1o3spXdybb5Ax5AO8L3sos41E 6boQu5uZ9DVEin7F+D4tXYWJqimVMCZSqEfvOpCG0XXMgqE/+3XBCeIKNuF2ZkFKah f/slUjBT87ePAH+VUFWEJdR7b90n34mjH2A7A0ZrAEqzfB4UXUf7aMXDGyRIirPACY dfhTkHUBVVIMQ== In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a03:4000:2a:2c1::1 (failed) Received-SPF: pass client-ip=2a03:4000:2a:2c1::1; envelope-from=hahnjo@hahnjo.de; helo=mail.hahnjo.de X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, 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:20960 Archived-At: --=-MhJcglaa3bpYFkAntlYR Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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]: > > +=C2=A0 SCM *smobs =3D scm_gc_malloc (sizeof(SCM) * SMOBS_COUNT, "smobs= "); > > + > > =C2=A0=C2=A0 int i; > > =C2=A0=C2=A0 mark_call_count =3D 0; > > =C2=A0=C2=A0 for (i =3D 0; i < SMOBS_COUNT; i++) > > -=C2=A0=C2=A0=C2=A0 make_x (); > > +=C2=A0=C2=A0=C2=A0 smobs[i] =3D make_x (); > > =C2=A0=C2=A0 scm_gc (); >=20 > smobs doesn't need to be protected for the whole function call, > until after the scm_gc() should be sufficient I think.=20 That's what the patch does, no? For reference, the whole function (after this patch) looks like: SCM *smobs =3D scm_gc_malloc (sizeof(SCM) * SMOBS_COUNT, "smobs"); int i; mark_call_count =3D 0; for (i =3D 0; i < SMOBS_COUNT; i++) smobs[i] =3D make_x ();=20 scm_gc ();=20 if (mark_call_count < SMOBS_COUNT) { =20 fprintf (stderr, "FAIL: SMOB mark function called for each SMOB\n"); exit (EXIT_FAILURE); } =20 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. Jonas --=-MhJcglaa3bpYFkAntlYR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEXw/5YGpL6H9VOgO2kcnDPSxhrNsFAmGXqDAACgkQkcnDPSxh rNuASgf+I23rae2bClOQcH+A4JkJNnr+fIngHumhTHCGVKWb1x6nwe6m9ImU6EVE w0+rMJupYHJemCsKAdq1kjQl2xF24/KUiJ4pOjU493JgVLSr6mAuaFrDNVBLHp2z avJGSZUru3MpNov31RPokpafCo2IRDxNrjQx0AuAf14iGA+sIFTW1hT6PbG4G8Rm oFaD3i8Z3GullUu0PlW8idOgyr0DvQz4694fZK3x8O8ohI7FkYxYLrbfedJujTS+ yokgkKLd6N8UeXMc6xB2jutUD2yOr5AsU+QwMrmLDph+jVIZ0AA9Dj9xUc6n4euZ Afr2FSja2A1Sik40fwHBIAvsK2/XUA== =SYqT -----END PGP SIGNATURE----- --=-MhJcglaa3bpYFkAntlYR--