This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: xfree/make_cleanup memory leak pattern?
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Khoo Yit Phang <khooyp at cs dot umd dot edu>
- Cc: gdb at sourceware dot org
- Date: Wed, 11 Jan 2012 01:30:35 +0100
- Subject: Re: xfree/make_cleanup memory leak pattern?
- References: <197CEDA3-0851-4FD2-B821-FD800C991F2D@cs.umd.edu>
On Wed, 11 Jan 2012 01:25:06 +0100, Khoo Yit Phang wrote:
> I noticed the following code pattern in various places in GDB:
> script = compute_python_string (cmd->body_list[0]);
> ...
> xfree (script);
>
> and also others like:
> full_path = tilde_expand (filename);
> ...
> cleanup = make_cleanup (xfree, full_path);
immediate_quit will cause:
fatal ("Quit");
which calls throw_exception in the end so all the intermediate cleanup
functions get called. You can trace/debug it yourself.
I do not see a leak there. Could you provide some debugging output proving
the memory is being leaked?
Thanks,
Jan