[Libvir] RFC: safer memory allocation APIs with compile time checking

Daniel P. Berrange berrange at redhat.com
Mon Apr 28 23:59:06 UTC 2008

On Mon, Apr 28, 2008 at 11:51:19PM +0000, David Lutterkort wrote:
> On Mon, 2008-04-28 at 20:16 +0100, Daniel P. Berrange wrote:
> > I've just hacked up a similar approach to the one DBus uses to fail
> > the 'nth' malloc 
> Does that fail exactly the nth malloc or the nth malloc and after (or
> from nth malloc to (n+k)th malloc) ? The latter two are more realistic
> for an OOM scenario, and make sure you don't blow up in some error
> handling routine.

My quick hack only did the nth, but if so desired we could easily do
the nth -> *n+k)th malloc at cost of polynomial expansion in number of
possiblities we want to check :-) Seriously though, we could probably
get enough coverage with values of k in (0..5)

Running the test suite native is easily fast enough. Running the checks
under valgrind was seriously slow but if we want to test for leaking
memory in cleanup paths its needed :-)

|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

More information about the libvir-list mailing list