From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 54813 invoked by alias); 26 Nov 2017 19:00:39 -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 54801 invoked by uid 89); 26 Nov 2017 19:00:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL,BAYES_00,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=no version=3.3.2 spammy= X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.87) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 26 Nov 2017 19:00:35 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway33.websitewelcome.com (Postfix) with ESMTP id EB9621603EE for ; Sun, 26 Nov 2017 13:00:33 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id J2ALePvexDL8rJ2ALeB2zg; Sun, 26 Nov 2017 13:00:33 -0600 Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:36362 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eJ2AL-0019AJ-NK; Sun, 26 Nov 2017 13:00:33 -0600 From: Tom Tromey To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] python: Fix memleak in do_start_initialization References: <20171126035308.12274-1-simon.marchi@polymtl.ca> Date: Sun, 26 Nov 2017 19:00:00 -0000 In-Reply-To: <20171126035308.12274-1-simon.marchi@polymtl.ca> (Simon Marchi's message of "Sat, 25 Nov 2017 22:53:08 -0500") Message-ID: <87y3msvp9r.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BWhitelist: no X-Source-L: No X-Exim-ID: 1eJ2AL-0019AJ-NK X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya) [71.218.90.63]:36362 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2017-11/txt/msg00672.txt.bz2 >>>>> "Simon" == Simon Marchi writes: Simon> While playing with valgrind, I noticed that the progname variable in Simon> do_start_initialization is not being freed (concat returns a malloc'ed Simon> string). Use a unique_xmalloc_ptr to manage it. I don't think this is quite correct. On the Python 2 branch, the code does this: Py_SetProgramName (progname); The docs for Py_SetProgramName say: The argument should point to a zero-terminated character string in static storage whose contents will not change for the duration of the program's execution. I think a comment referring to the Python docs would be better. And, freeing progname on the Python 3 branch is ok. Maybe the Python 2 branch could pass "progname.release ()". Tom