From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119271 invoked by alias); 21 Jun 2018 01:39:55 -0000 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 Received: (qmail 119235 invoked by uid 89); 21 Jun 2018 01:39:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1061 X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Jun 2018 01:39:54 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w5L1dlgL016095 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 20 Jun 2018 21:39:52 -0400 Received: by simark.ca (Postfix, from userid 112) id 118DD1EF29; Wed, 20 Jun 2018 21:39:47 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 07DF91E481; Wed, 20 Jun 2018 21:39:45 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 21 Jun 2018 01:39:00 -0000 From: Simon Marchi To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Fix a memory leak in py-param.c In-Reply-To: <20180620213836.3980-1-tom@tromey.com> References: <20180620213836.3980-1-tom@tromey.com> Message-ID: <82b158062718433683eca9daef46a66d@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.6 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Thu, 21 Jun 2018 01:39:47 +0000 X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00507.txt.bz2 On 2018-06-20 17:38, Tom Tromey wrote: > Mark Wielaard pointed out this memory leak to me: > > ==17633== 775 bytes in 1 blocks are definitely lost in loss record > 13,346 of 13,967 > ==17633== at 0x4C2DB6B: malloc (vg_replace_malloc.c:299) > ==17633== by 0x6652B7: xmalloc (common-utils.c:45) > ==17633== by 0xC4C889: xstrdup (xstrdup.c:34) > ==17633== by 0x5A71FD: unicode_to_encoded_string(_object*, char > const*) (py-utils.c:81) > ==17633== by 0x5A73EB: python_string_to_host_string(_object*) > (py-utils.c:158) > ==17633== by 0x59CC6C: get_doc_string(_object*, _object*) > (py-param.c:334) > ==17633== by 0x59D2AA: parmpy_init(_object*, _object*, > _object*) (py-param.c:728) > > The bug here is that parmpy_init is written as though > add_setshow_generic takes ownership of its doc-string arguments. > However, it does not. This patch fixes the bug in a straightforward > way and also applies some missing constification to make the problem > more apparent. > > Tested on x86-64 Fedora 26. LGTM, thanks. Simon