qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for 4.2 0/3] require newer glib2 to enable autof


From: Daniel P . Berrangé
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
User-agent: Mutt/1.12.0 (2019-05-25)

On Thu, Jul 25, 2019 at 10:13:11AM +0100, Peter Maydell wrote:
> On Tue, 23 Jul 2019 at 16:49, Daniel P. Berrangé <address@hidden> 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 :|



reply via email to

[Prev in Thread] Current Thread [Next in Thread]