From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrew Gaylard Newsgroups: gmane.lisp.guile.user Subject: Re: smob gc protection, and inheritance Date: Thu, 05 Sep 2013 21:43:54 +0200 Message-ID: <5228DEFA.4030700@computer.org> References: <87y57c70js.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1378410257 22377 80.91.229.3 (5 Sep 2013 19:44:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Sep 2013 19:44:17 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Sep 05 21:44:19 2013 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 1VHfTW-0000RV-1A for guile-user@m.gmane.org; Thu, 05 Sep 2013 21:44:18 +0200 Original-Received: from localhost ([::1]:33537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHfTV-0007RW-M2 for guile-user@m.gmane.org; Thu, 05 Sep 2013 15:44:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHfTJ-0007RG-41 for guile-user@gnu.org; Thu, 05 Sep 2013 15:44:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHfTE-0000s9-NJ for guile-user@gnu.org; Thu, 05 Sep 2013 15:44:05 -0400 Original-Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:65098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHfTE-0000rv-Fs for guile-user@gnu.org; Thu, 05 Sep 2013 15:44:00 -0400 Original-Received: by mail-wi0-f177.google.com with SMTP id cb5so12728wib.4 for ; Thu, 05 Sep 2013 12:43:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=7FExlefxfa96Q0EQKD7k1lu7Th8PjcvmnmK4gpYB6FM=; b=ZzNDOUcq32kpBMWHMPn0ng47Rie8wfWiGD6VXTDDQ7740omZQCPtxlkWEXSfutyNXW c3th0pJdQAx0MY5xDrY9U7YLIjABW8d3aHqzzGHXU27+zlGgjs5mADpsRhYe8L8+WzXS y7we6l+mrfp9Yxy1SjkxWe5kLIeyyD9RqIykNmrjJEU+GE+Z628KbCL/Uvb5NWL8ynqv xfhTC5PzcOqXIdu+if42f3Dx9lv1khkVIe3i7khwSNJwdiKXeYAE8OMzrVuOdfNvl06Y fekTGP+ayIkCJ5mvoSW0bsk/Q79z9UtL4urH2DlP/qPPHIWkcleml3UdTWWFTwvv8t18 gZQg== X-Received: by 10.180.39.180 with SMTP id q20mr7599186wik.13.1378410238899; Thu, 05 Sep 2013 12:43:58 -0700 (PDT) Original-Received: from [10.0.0.3] (41-133-147-168.dsl.mweb.co.za. [41.133.147.168]) by mx.google.com with ESMTPSA id iz19sm14234364wic.9.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Sep 2013 12:43:58 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; SunOS sun4u; rv:17.0) Gecko/20130802 Thunderbird/17.0.8 In-Reply-To: <87y57c70js.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::231 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:10754 Archived-At: On 09/04/13 23:13, Ludovic Courtès wrote: > Hi Doug, > > Doug Evans skribis: >> 3) The docs aren't as clear as they could be on whether the "smob" >> free function needs to scm_gc_free all results of calls to scm_gc_malloc >> made when constructing the smob. IIUC, this is not necessary. > The ‘scm_gc_free’ function doesn’t need to be called nowadays, because > the GC automatically frees ‘scm_gc_malloc’ regions when they are no > longer referenced. > > So chances are you don’t even need a SMOB ‘free’ function. > >> However, why does the image example do this? > Indeed, the ‘mark’ and ‘free’ functions in that example could be removed > altogether, since the only resources associated with the SMOB is memory > returned by ‘scm_gc_malloc’. Hi Ludo', Thanks for this information -- it helps answer my guile-dbi question (http://lists.gnu.org/archive/html/guile-user/2013-08/msg00133.html). You say "chances are" -- so when does one need a free() function? I suspect that guile-dbi does require one, because it has to close the DB handle; right? Since the SMOB was allocated with scm_gc_malloc, and since the things it mark()s are all SCM types, does it follow that it's safe not to mark() it at all? Where can I find more information about how guile and its GC work? In particular, is there a FAQ guide to debugging GC problems? I'm concerned about leaks, objects collected/freed too early, and similar bugs. BTW: all of this is in the context of guile-2.0.9. Many thanks, -- Andrew