This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] PR gdb/17210 - fix possible memory leak in read_memory_robust
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Tom Tromey <tom at tromey dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Wed, 29 Jun 2016 10:27:29 +0100
- Subject: Re: [RFA] PR gdb/17210 - fix possible memory leak in read_memory_robust
- Authentication-results: sourceware.org; auth=none
- References: <1465490013-15336-1-git-send-email-tom at tromey dot com> <CAH=s-PMjZN9byLwAGs+yQjEhDzMJEe0RxGuT-tg89+DFxgk6ew at mail dot gmail dot com> <39ec8a24-e86d-99f8-3fa0-d73e17d3a639 at redhat dot 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 (éå)