Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Pedro Alves <palves@redhat.com>
Cc: Tom Tromey <tom@tromey.com>,
		"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [RFA] PR gdb/17210 - fix possible memory leak in read_memory_robust
Date: Wed, 29 Jun 2016 09:27:00 -0000	[thread overview]
Message-ID: <CAH=s-POZ4jh8RAdgiB5VMx0Bco91zN1GtCr1Ot7vJWj9NNHKwg@mail.gmail.com> (raw)
In-Reply-To: <39ec8a24-e86d-99f8-3fa0-d73e17d3a639@redhat.com>

On Tue, Jun 28, 2016 at 6:47 PM, Pedro Alves <palves@redhat.com> wrote:
> On 06/28/2016 11:42 AM, Yao Qi wrote:
>> On Thu, Jun 9, 2016 at 5:33 PM, Tom Tromey <tom@tromey.com> wrote:
>>>
>>>  VEC(memory_read_result_s) *
>>> @@ -1810,6 +1810,8 @@ read_memory_robust (struct target_ops *ops,
>>>  {
>>>    VEC(memory_read_result_s) *result = 0;
>>>    int unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch ());
>>> +  struct cleanup *cleanup = make_cleanup (free_memory_read_result_vector,
>>> +                                         &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.

-- 
Yao (齐尧)


      reply	other threads:[~2016-06-29  9:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09 16:34 Tom Tromey
2016-06-28 10:43 ` Yao Qi
2016-06-28 14:40   ` Tom Tromey
2016-06-28 17:48   ` Pedro Alves
2016-06-29  9:27     ` Yao Qi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH=s-POZ4jh8RAdgiB5VMx0Bco91zN1GtCr1Ot7vJWj9NNHKwg@mail.gmail.com' \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox