From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12765 invoked by alias); 29 Jun 2016 09:27:47 -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 12742 invoked by uid 89); 29 Jun 2016 09:27:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-ob0-f177.google.com Received: from mail-ob0-f177.google.com (HELO mail-ob0-f177.google.com) (209.85.214.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 29 Jun 2016 09:27:31 +0000 Received: by mail-ob0-f177.google.com with SMTP id ru5so17400225obc.1 for ; Wed, 29 Jun 2016 02:27:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=0n4xv5gJdgm93uXXVVbNxfDRDczxlzskL2UPTB2tfd8=; b=dlc3p9kCJGetwHGIhekWCQCbNg4KZRTeP8bR/L6aJa4Bx76AE/zt5z4inopZ8rcOCp rNxsiP/aXCObKCoCZatpdBJlgPvGg+oe/W54wtHBhVft28r1DEnEyDvHhTpxsq/Hg2HJ P7RAniMh13R5nXmvV7at84qS89MB3/nkJq3TiETsJoVyC8SCUcSDGGAxQalK8xh6SJFY uWGfCBICUj+vZUbZKTNY3SMXqzhF54BYabEY2PtSBhZdXvJOXYokxQoAMHtbprXciiPg Rzv2oPA9WHxBintfBwrH8mepqQgHzeS9ApGUXZZx+obQS5l50/ib4n0YZhkzSJd6pOwe is5g== X-Gm-Message-State: ALyK8tLWANyVLGDzOh/rKvLjTWUOIWI1+jkvfkV/1S7/2OgX3l2j6923RsK138hyj8A4frUYSgrNIGdUbQHa8A== X-Received: by 10.157.5.194 with SMTP id 60mr4569107otd.161.1467192449701; Wed, 29 Jun 2016 02:27:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.62.70 with HTTP; Wed, 29 Jun 2016 02:27:29 -0700 (PDT) In-Reply-To: <39ec8a24-e86d-99f8-3fa0-d73e17d3a639@redhat.com> References: <1465490013-15336-1-git-send-email-tom@tromey.com> <39ec8a24-e86d-99f8-3fa0-d73e17d3a639@redhat.com> From: Yao Qi Date: Wed, 29 Jun 2016 09:27:00 -0000 Message-ID: Subject: Re: [RFA] PR gdb/17210 - fix possible memory leak in read_memory_robust To: Pedro Alves Cc: Tom Tromey , "gdb-patches@sourceware.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg00494.txt.bz2 On Tue, Jun 28, 2016 at 6:47 PM, Pedro Alves wrote: > On 06/28/2016 11:42 AM, Yao Qi wrote: >> On Thu, Jun 9, 2016 at 5:33 PM, Tom Tromey wrote: >>> >>> VEC(memory_read_result_s) * >>> @@ -1810,6 +1810,8 @@ read_memory_robust (struct target_ops *ops, >>> { >>> VEC(memory_read_result_s) *result =3D 0; >>> int unit_size =3D gdbarch_addressable_memory_unit_size (target_gdbar= ch ()); >>> + struct cleanup *cleanup =3D make_cleanup (free_memory_read_result_ve= ctor, >>> + &result); >>> >> >> result is a local variable on stack, so its address is meaningless when = the >> exception is throw, because the stack has already been destroyed. > > Can you clarify? > Cleanups do run before the stack is destroyed. See most > free_current_contents users. Urr.. right... do_cleanups is called when the exception is thrown where the stack is not destroyed yet. I thought do_cleanups is called when gdb goes back to the top level in this case. Tom, the patch is good to me then. --=20 Yao (=E9=BD=90=E5=B0=A7)