From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17646 invoked by alias); 6 Oct 2010 16:19:30 -0000 Received: (qmail 17631 invoked by uid 22791); 6 Oct 2010 16:19:28 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Oct 2010 16:19:18 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o96GJFjm008733 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 6 Oct 2010 12:19:16 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o96GJE50013234; Wed, 6 Oct 2010 12:19:15 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o96GJDbF007944; Wed, 6 Oct 2010 12:19:14 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 6E3F5379C1A; Wed, 6 Oct 2010 10:19:12 -0600 (MDT) From: Tom Tromey To: Ali Lakhia Cc: gdb-patches@sourceware.org Subject: Re: [patch] Memory leak fixes References: Date: Wed, 06 Oct 2010 16:19:00 -0000 In-Reply-To: (Ali Lakhia's message of "Tue, 5 Oct 2010 16:47:00 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: 2010-10/txt/msg00077.txt.bz2 >>>>> "Ali" =3D=3D Ali Lakhia writes: Ali> I found the leak using a static checker. It is known to have false Ali> positives! :-) Ok, I suspected that might be the case. Ali> =C2=A0 =C2=A0do_cleanups (cleanup_chain); Ali> + =C2=A0xfree (filename); Tom> This one is also covered by a cleanup. Ali> I don't see any cleanup calls. filename gets allocated by Ali> build_address_symbolic() and nothing is freeing it as far as I can Ali> tell. Near the top of the function: struct cleanup *cleanup_chain =3D make_cleanup (free_current_contents, &n= ame); make_cleanup (free_current_contents, &filename); This installs a cleanup that frees `name'. It is run by the do_cleanups call at the end of the function. I think the GDB internals manual has a section on "cleanups" and how they interact with GDB's exception mechanism. An analyzer looking for leaks has to know about this, because it is used pervasively throughout GDB. Tom