public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Khoo Yit Phang <khooyp@cs.umd.edu>
To: gdb@sourceware.org
Cc: Khoo Yit Phang <khooyp@cs.umd.edu>
Subject: xfree/make_cleanup memory leak pattern?
Date: Wed, 11 Jan 2012 00:25:00 -0000	[thread overview]
Message-ID: <197CEDA3-0851-4FD2-B821-FD800C991F2D@cs.umd.edu> (raw)

Hi,

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); 

If I understand correctly, wouldn't these patterns lead to a memory leak if the user manages to trigger a SIGINT (with immediate_quit in effect) at the "..." in between the memory allocation and xfree/make_cleanup? It's a tiny window in most cases, but something like compute_python_string could take some time.

Yit
January 10, 2012

             reply	other threads:[~2012-01-11  0:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11  0:25 Khoo Yit Phang [this message]
2012-01-11  0:31 ` Jan Kratochvil
2012-01-11  0:32   ` Jan Kratochvil
2012-01-11 14:31     ` Tom Tromey

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=197CEDA3-0851-4FD2-B821-FD800C991F2D@cs.umd.edu \
    --to=khooyp@cs.umd.edu \
    --cc=gdb@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).