From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH for 4.2 0/3] require newer glib2 to enable autofree'ing of stack variables exiting scope
Date: Thu, 25 Jul 2019 10:24:05 +0100 [thread overview]
Message-ID: <20190725092405.GB6930@redhat.com> (raw)
In-Reply-To: <CAFEAcA-jz2Dsso1cBxEhCu7kq++T1vH--Q_AuBTYzxQxttDNCw@mail.gmail.com>
On Thu, Jul 25, 2019 at 10:13:11AM +0100, Peter Maydell wrote:
> On Tue, 23 Jul 2019 at 16:49, Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > Both GCC and CLang support a C extension attribute((cleanup)) which
> > allows you to define a function that is invoked when a stack variable
> > exits scope. This typically used to free the memory allocated to it,
> > though you're not restricted to this. For example it could be used to
> > unlock a mutex.
>
> Does Coverity handle this? Can it be made to wire up this kind
> of deallocation into checks of use-after-free/memory leaks/etc?
I believe so, in so much as it has not complained about leaks in
libvirt where we've removed the free() calls in favour of the
attribute(cleanup) annotations. I'm presuming this is because the
free() calls do still exist - they're simply automatically added
in all paths that exist a code scope. You can still see the free()
calls in GDB stack traces for example.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
prev parent reply other threads:[~2019-07-25 9:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 15:48 [Qemu-devel] [PATCH for 4.2 0/3] require newer glib2 to enable autofree'ing of stack variables exiting scope Daniel P. Berrangé
2019-07-23 15:48 ` [Qemu-devel] [PATCH for 4.2 1/3] glib: bump min required glib library version to 2.48 Daniel P. Berrangé
2019-07-23 16:02 ` Thomas Huth
2019-07-23 16:04 ` Daniel P. Berrangé
2019-07-23 15:48 ` [Qemu-devel] [PATCH for 4.2 2/3] crypto: define cleanup functions for use with g_autoptr Daniel P. Berrangé
2019-07-23 15:48 ` [Qemu-devel] [PATCH for 4.2 3/3] crypto: use auto cleanup for many stack variables Daniel P. Berrangé
2019-07-23 19:17 ` [Qemu-devel] [PATCH for 4.2 0/3] require newer glib2 to enable autofree'ing of stack variables exiting scope no-reply
2019-07-25 8:38 ` Stefan Hajnoczi
2019-07-25 9:13 ` Peter Maydell
2019-07-25 9:24 ` Daniel P. Berrangé [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=20190725092405.GB6930@redhat.com \
--to=berrange@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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 NNTP newsgroup(s).