From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89765 invoked by alias); 8 Dec 2018 15:54:21 -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 89752 invoked by uid 89); 8 Dec 2018 15:54:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 08 Dec 2018 15:54:19 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2556C3084243; Sat, 8 Dec 2018 15:54:18 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FC5A60FB0; Sat, 8 Dec 2018 15:54:17 +0000 (UTC) Subject: Re: [RFA] Fix leak by using td_ta_delete() to deregister target process and deallocate internal process handle. To: Philippe Waroquiers , gdb-patches@sourceware.org References: <20181207203410.29636-1-philippe.waroquiers@skynet.be> From: Pedro Alves Message-ID: <22f21481-7efa-2836-235b-d2d803f26220@redhat.com> Date: Sat, 08 Dec 2018 15:54:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181207203410.29636-1-philippe.waroquiers@skynet.be> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-12/txt/msg00106.txt.bz2 On 12/07/2018 08:34 PM, Philippe Waroquiers wrote: > > +static const char *thread_db_err_str (td_err_e err); > + > /* When PID has exited or has been detached, we no longer want to keep > track of it as using libpthread. Call this function to discard > thread_db related info related to PID. Note that this closes > @@ -273,6 +276,17 @@ delete_thread_db_info (int pid) > if (info == NULL) > return; > > + if (info->thread_agent != NULL && info->td_ta_delete_p != NULL) > + { > + td_err_e err; > + > + err = info->td_ta_delete_p (info->thread_agent); You can declare and initialize in the same line/statement. > + if (err != TD_OK) > + warning (_("Cannot deregister target process: %s"), > + thread_db_err_str (err)); Should mention libthread_db here, otherwise I think this warning may appear mystifying. Maybe mention the PID as well, in case we're debugging more than one process? Like: warning (_("Cannot deregister process %d from libthread_db: %s"), pid, thread_db_err_str (err)); Otherwise looks fine. Please push. Thanks! Pedro Alves