From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.lisp.guile.user Subject: Re: Need for scm_remember_upto_here_* in guile-2.0 Date: Tue, 22 Sep 2015 19:08:45 +0200 Message-ID: <877fnibcv6.fsf@fencepost.gnu.org> References: <20150912132725.5a5e539c@bother.homenet> <87d1xamrmz.fsf@gnu.org> <87fv26bhlw.fsf@fencepost.gnu.org> <878u7yfmmw.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1442941743 7241 80.91.229.3 (22 Sep 2015 17:09:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Sep 2015 17:09:03 +0000 (UTC) Cc: Ludovic =?iso-8859-1?Q?Court=E8s?= , guile-user@gnu.org To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Sep 22 19:09:03 2015 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZeR3u-0003tn-NN for guile-user@m.gmane.org; Tue, 22 Sep 2015 19:09:02 +0200 Original-Received: from localhost ([::1]:41619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeR3u-0003ce-Ab for guile-user@m.gmane.org; Tue, 22 Sep 2015 13:09:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeR3l-0003bD-Jv for guile-user@gnu.org; Tue, 22 Sep 2015 13:08:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeR3h-0006nW-Q9 for guile-user@gnu.org; Tue, 22 Sep 2015 13:08:53 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:37502) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeR3e-0006mB-FK; Tue, 22 Sep 2015 13:08:46 -0400 Original-Received: from localhost ([127.0.0.1]:51321 helo=lola) by fencepost.gnu.org with esmtp (Exim 4.82) (envelope-from ) id 1ZeR3d-0000ae-La; Tue, 22 Sep 2015 13:08:46 -0400 Original-Received: by lola (Postfix, from userid 1000) id 3DFDCDF2A1; Tue, 22 Sep 2015 19:08:45 +0200 (CEST) In-Reply-To: <878u7yfmmw.fsf@netris.org> (Mark H. Weaver's message of "Tue, 22 Sep 2015 12:24:07 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::e X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:12027 Archived-At: Mark H Weaver writes: > David Kastrup writes: > >> ludo@gnu.org (Ludovic Court=E8s) writes: >> >>> In practice scm_remember_upto_here_* is useless with libgc, since libgc >>> also tracks pointers in registers. >> >> Sounds like a big non-sequitur. scm_remember_upto_here_* is for keeping >> SCM values active (including in registers). Any conversion of an SCM >> value to some other data depending on it will not protect the SCM value >> as such and may lead to collection/finalization of the SCM cell (calling >> guardians, removing from weak hashtables and so on). > > I think David is right. Consider the following case: a SMOB contains a > pointer to a block allocated by 'malloc' and freed by the SMOB freeing > procedure. Some C code starts with a SCM value for that SMOB, uses it > to obtain a pointer to the malloc'd block, and then discards the SCM > value and proceeds to do a long-running job on the malloc'd block. If > there are no other references to the SCM value, Boehm GC can free the > SMOB and call its finalizer, which frees the malloc'd block. The > long-running job in C continues to access the freed block. > > Am I missing something? Well, the underlying idea was probably not to free any memory in the finalizer and have the malloc'd block be independently protected/freed by libgc. If you do things like that, you don't have any structural integrity associated with an SCM value. Its various components will be independently protected from low-level collection by libgc and the SCM value might be gone/finalized considerably before processing on parts of it ends. At any rate, the statement at issue was >>> In practice scm_remember_upto_here_* is useless with libgc, since >>> libgc also tracks pointers in registers. and registers containing SCM values were already tracked in version 1.8 (since registers are saved in the stack frame when functions possibly invoking a garbage collection are called, tracking SCM values in registers is not a challenge separate from marking the whole stack). scm_remember_upto_here_* is not about SCM values being in registers but rather about the compiler not bothering to keep them around at all. --=20 David Kastrup