From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7306 invoked by alias); 16 Apr 2009 21:36:28 -0000 Received: (qmail 7297 invoked by uid 22791); 16 Apr 2009 21:36:27 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 16 Apr 2009 21:36:21 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n3GLa9bB021322 for ; Thu, 16 Apr 2009 17:36:09 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n3GLa7Nk014047; Thu, 16 Apr 2009 17:36:08 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n3GLa6cp010770; Thu, 16 Apr 2009 17:36:07 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id n3GLa5p1012122; Thu, 16 Apr 2009 23:36:05 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.2/Submit) id n3GLa464012121; Thu, 16 Apr 2009 23:36:04 +0200 Date: Thu, 16 Apr 2009 21:36:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [patch] [0/5] Types reference counting (for VLA+Python) Message-ID: <20090416213604.GA11887@host0.dyn.jankratochvil.net> References: <20090411102003.GA32624@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-04/txt/msg00389.txt.bz2 On Thu, 16 Apr 2009 21:32:11 +0200, Tom Tromey wrote: > FWIW, you can get a memory leak here with CVS gdb by setting a > convenience variable to a value whose type comes from an objfile, > closing all the objfiles ("file"), and then assigning a new value to > the convenience variable. In this case nothing frees the type. There will be still many leaks like this one, more places should change alloc_type to alloc_type_discardable and possibly also include forgotten type_incref/type_decref. Going to patch this specific case separately. > Jan> To be true there exist some artificial temporary types such as in > Jan> value_cast > [...] > Jan> , these can be freed by this implemented garbage collecting > Jan> infrastructure. These are already leaking in current FSF GDB; > Jan> fix based on this framework is currently not a part of this > Jan> patchset. > > Why is that? (It doesn't matter in terms of acceptance, I'm just > curious.) value_cast for TYPE_CODE_ARRAY has a comment: /* FIXME-type-allocation: need a way to free this type when we are done with it. */ because it does create_array_type ((struct type *) NULL, element_type, range_type)); used for resulting ARG2. ARG2 will get freed by free_all_values but as this new array type was not marked as reclaimable it will be leaked as permanent. > Jan> * Should the default allocation of types (alloc_type (NULL)) > Jan> provide permanent type or a garbage collectable type? > Jan> = Currently it creates a permanent type. > > Too bad the other approach didn't work out. Where do all these > permanent types come from? Not just init_type, I gather. For example _initialize_values() does something like init_type but using alloc_type for it. create_array_type needs to inherit the behavior from both its range type and the index type. > It seems strange to have a type-crawling garbage collector *and* > reference counting. But I suppose this is because enumerating the > root set is tricky. As already found there are (IMO) few places needing to allocate reclaimable types it may be doable. Thanks for the hint, I will try to rework it or at least verify if it is viable. Thanks, Jan