From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Pedro Alves <palves@redhat.com>, gdb-patches@sourceware.org
Subject: Re: RFC: introduce scoped cleanups
Date: Mon, 03 Jun 2013 06:07:00 -0000 [thread overview]
Message-ID: <20130603060716.GC12363@adacore.com> (raw)
In-Reply-To: <8738t2q4o2.fsf@fleche.redhat.com>
> My one concern about this code is that, if a stack cleanup should be
> leaked, then any future cleanup operation will refer to invalid memory.
>
> Right now, cleanup failures like this are a memory leak with the
> possibility of wrong behavior -- but the new way seems more directly
> fatal.
>
> Another option would be to allocate cleanups on an obstack.
> This would often be efficient and would avoid the above problem.
A very valid concern, IMO! I've never seen heap allocation as
a reason for concern with respect to performance, and thus have
never hesitated calling malloc. The only reason I have prefered
alloca whenever possible is that it allows me to be lazy :-)!
But this made me realize something: Why would someone want to do
stack-cleanups instead of just calling alloca directly? Since
alloca is basically a call-and-forget, what's the advantage of
going through a stack-based cleanup?
Regardless of the above, I like the idea of performing the cleanups
on an obstack; fast and yet a little more resilient to programming
errors. Not sure if that would be something easy to implement or not,
though.
--
Joel
next prev parent reply other threads:[~2013-06-03 6:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-09 18:56 Tom Tromey
2013-05-30 20:09 ` Tom Tromey
2013-05-31 6:11 ` Joel Brobecker
2013-05-31 15:56 ` Tom Tromey
2013-05-31 16:15 ` Pedro Alves
2013-05-31 20:24 ` Tom Tromey
2013-06-03 6:07 ` Joel Brobecker [this message]
2013-06-05 17:44 ` Tom Tromey
2013-07-16 20:33 ` 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=20130603060716.GC12363@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=tromey@redhat.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