Bug 961155 - g_string_new + virEventRegisterDefaultImpl causes coredump
g_string_new + virEventRegisterDefaultImpl causes coredump
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
unspecified
x86_64 Linux
unspecified Severity low
: ---
: ---
Assigned To: Libvirt Maintainers
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-08 20:50 EDT by Jesse Cook
Modified: 2016-04-09 19:09 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-04-09 19:09:41 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
coredump (1.29 MB, application/octet-stream)
2013-05-08 20:50 EDT, Jesse Cook
no flags Details

  None (edit)
Description Jesse Cook 2013-05-08 20:50:15 EDT
Created attachment 745474 [details]
coredump

Description of problem:

This should not crash:

#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
#include <glib.h>

int main(int argc, char* argv[])
{
    GString* foo = g_string_new("This should work");
    virEventRegisterDefaultImpl();
    return 0;
}


Version-Release number of selected component (if applicable):

Libvirt compiled from source using Debian Wheezy glib version specified below:
$ git rev-parse HEAD
3dfc2b71aa070dad6e2a460705426031e77889e2

On Debian Wheezy:
ii  libvirt-bin                                      0.9.12-11.1                  
ii  libvirt-dev                                      0.9.12-11.1                  
ii  libvirt-doc                                      0.9.12-11.1  
ii  libvirt0                                         0.9.12-11.1
ii  libvirtodbc0                                     6.1.4+dfsg1-7
ii  libglib-object-introspection-perl                0.009-1
ii  libglib-perl                                     3:1.260-1
ii  libglib2.0-0:amd64                               2.33.12+really2.32.4-5
ii  libglib2.0-bin                                   2.33.12+really2.32.4-5
ii  libglib2.0-data                                  2.33.12+really2.32.4-5
ii  libglib2.0-dev                                   2.33.12+really2.32.4-5
ii  libglib2.0-doc                                   2.33.12+really2.32.4-5


How reproducible:

100% of the time every time

Steps to Reproduce:
1. Copy code to file
2. Compile (gcc -I/usr/src/libvirt/include/libvirt/ -L/usr/src/libvirt/src/.libs/ -lvirt `pkg-config --cflags glib-2.0 --libs glib-2.0` -Wl,-rpath=/usr/src/libvirt/src/.libs /tmp/libvirt-test.c)
3. ./a.out
  
Actual results:

$ ./a.out 
*** glibc detected *** ./a.out: free(): invalid pointer: 0x0000000000b80ed0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x76d76)[0x7fcfc123fd76]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x6c)[0x7fcfc1244aac]
/usr/src/libvirt/src/.libs/libvirt.so.0(virFree+0x39)[0x7fcfc18aa189]
/usr/src/libvirt/src/.libs/libvirt.so.0(virResetError+0x26)[0x7fcfc18be586]
/usr/src/libvirt/src/.libs/libvirt.so.0(virEventRegisterDefaultImpl+0x46)[0x7fcfc18bfcf6]
./a.out[0x40076e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd)[0x7fcfc11e7ead]
./a.out[0x400669]
======= Memory map: ========
00400000-00401000 r-xp 00000000 fe:02 2360908                            /home/jesse/src/slamr-modules-domain-monitor/a.out
00600000-00601000 rw-p 00000000 fe:02 2360908                            /home/jesse/src/slamr-modules-domain-monitor/a.out
00b80000-00ba1000 rw-p 00000000 00:00 0                                  [heap]
7fcfb4000000-7fcfb4021000 rw-p 00000000 00:00 0 
7fcfb4021000-7fcfb8000000 ---p 00000000 00:00 0 
7fcfbbf3a000-7fcfbbf3d000 r-xp 00000000 fe:00 922962                     /lib/x86_64-linux-gnu/libkeyutils.so.1.4
7fcfbbf3d000-7fcfbc13c000 ---p 00003000 fe:00 922962                     /lib/x86_64-linux-gnu/libkeyutils.so.1.4
7fcfbc13c000-7fcfbc13d000 r--p 00002000 fe:00 922962                     /lib/x86_64-linux-gnu/libkeyutils.so.1.4
7fcfbc13d000-7fcfbc13e000 rw-p 00003000 fe:00 922962                     /lib/x86_64-linux-gnu/libkeyutils.so.1.4
7fcfbc13e000-7fcfbc146000 r-xp 00000000 fe:00 3416921                    /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7fcfbc146000-7fcfbc345000 ---p 00008000 fe:00 3416921                    /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7fcfbc345000-7fcfbc346000 r--p 00007000 fe:00 3416921                    /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7fcfbc346000-7fcfbc347000 rw-p 00008000 fe:00 3416921                    /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7fcfbc347000-7fcfbc34a000 r-xp 00000000 fe:00 919347                     /lib/x86_64-linux-gnu/libcom_err.so.2.1
7fcfbc34a000-7fcfbc549000 ---p 00003000 fe:00 919347                     /lib/x86_64-linux-gnu/libcom_err.so.2.1
7fcfbc549000-7fcfbc54a000 r--p 00002000 fe:00 919347                     /lib/x86_64-linux-gnu/libcom_err.so.2.1
7fcfbc54a000-7fcfbc54b000 rw-p 00003000 fe:00 919347                     /lib/x86_64-linux-gnu/libcom_err.so.2.1
7fcfbc54b000-7fcfbc571000 r-xp 00000000 fe:00 3416906                    /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7fcfbc571000-7fcfbc771000 ---p 00026000 fe:00 3416906                    /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7fcfbc771000-7fcfbc772000 r--p 00026000 fe:00 3416906                    /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7fcfbc772000-7fcfbc773000 rw-p 00027000 fe:00 3416906                    /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7fcfbc773000-7fcfbc774000 rw-p 00000000 00:00 0 
7fcfbc774000-7fcfbc83d000 r-xp 00000000 fe:00 3416915                    /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7fcfbc83d000-7fcfbca3c000 ---p 000c9000 fe:00 3416915                    /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7fcfbca3c000-7fcfbca46000 r--p 000c8000 fe:00 3416915                    /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7fcfbca46000-7fcfbca48000 rw-p 000d2000 fe:00 3416915                    /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7fcfbca48000-7fcfbca61000 r-xp 00000000 fe:00 3429686                    /usr/lib/x86_64-linux-gnu/librtmp.so.0
7fcfbca61000-7fcfbcc61000 ---p 00019000 fe:00 3429686                    /usr/lib/x86_64-linux-gnu/librtmp.so.0
7fcfbcc61000-7fcfbcc62000 rw-p 00019000 fe:00 3429686                    /usr/lib/x86_64-linux-gnu/librtmp.so.0
7fcfbcc62000-7fcfbcc9e000 r-xp 00000000 fe:00 3416910                    /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7fcfbcc9e000-7fcfbce9e000 ---p 0003c000 fe:00 3416910                    /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7fcfbce9e000-7fcfbce9f000 r--p 0003c000 fe:00 3416910                    /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7fcfbce9f000-7fcfbcea1000 rw-p 0003d000 fe:00 3416910                    /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7fcfbcea1000-7fcfbceed000 r-xp 00000000 fe:00 3417413                    /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.8.3
7fcfbceed000-7fcfbd0ed000 ---p 0004c000 fe:00 3417413                    /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.8.3
7fcfbd0ed000-7fcfbd0ef000 r--p 0004c000 fe:00 3417413                    /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.8.3
7fcfbd0ef000-7fcfbd0f0000 rw-p 0004e000 fe:00 3417413                    /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.8.3
7fcfbd0f0000-7fcfbd0f2000 rw-p 00000000 00:00 0 
7fcfbd0f2000-7fcfbd100000 r-xp 00000000 fe:00 3417416                    /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.8.3
7fcfbd100000-7fcfbd2ff000 ---p 0000e000 fe:00 3417416                    /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.8.3
7fcfbd2ff000-7fcfbd300000 r--p 0000d000 fe:00 3417416                    /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.8.3
7fcfbd300000-7fcfbd301000 rw-p 0000e000 fe:00 3417416                    /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.8.3
7fcfbd301000-7fcfbd333000 r-xp 00000000 fe:00 3418861                    /usr/lib/x86_64-linux-gnu/libidn.so.11.6.8
7fcfbd333000-7fcfbd533000 ---p 00032000 fe:00 3418861                    /usr/lib/x86_64-linux-gnu/libidn.so.11.6.8
7fcfbd533000-7fcfbd534000 r--p 00032000 fe:00 3418861                    /usr/lib/x86_64-linux-gnu/libidn.so.11.6.8
7fcfbd534000-7fcfbd535000 rw-p 00033000 fe:00 3418861                    /usr/lib/x86_64-linux-gnu/libidn.so.11.6.8
7fcfbd535000-7fcfbd538000 r-xp 00000000 fe:00 919446                     /lib/x86_64-linux-gnu/libgpg-error.so.0.8.0
7fcfbd538000-7fcfbd737000 ---p 00003000 fe:00 919446                     /lib/x86_64-linux-gnu/libgpg-error.so.0.8.0
7fcfbd737000-7fcfbd738000 rw-p 00002000 fe:00 919446                     /lib/x86_64-linux-gnu/libgpg-error.so.0.8.0
7fcfbd738000-7fcfbd74b000 r-xp 00000000 fe:00 924552                     /lib/x86_64-linux-gnu/libresolv-2.13.so
7fcfbd74b000-7fcfbd94a000 ---p 00013000 fe:00 924552                     /lib/x86_64-linux-gnu/libresolv-2.13.so
7fcfbd94a000-7fcfbd94b000 r--p 00012000 fe:00 924552                     /lib/x86_64-linux-gnu/libresolv-2.13.so
7fcfbd94b000-7fcfbd94c000 rw-p 00013000 fe:00 924552                     /lib/x86_64-linux-gnu/libresolv-2.13.so
7fcfbd94c000-7fcfbd94e000 rw-p 00000000 00:00 0 
7fcfbd94e000-7fcfbd95f000 r-xp 00000000 fe:00 3418840                    /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.0.0
7fcfbd95f000-7fcfbdb5e000 ---p 00011000 fe:00 3418840                    /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.0.0
7fcfbdb5e000-7fcfbdb5f000 r--p 00010000 fe:00 3418840                    /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.0.0
7fcfbdb5f000-7fcfbdb60000 rw-p 00011000 fe:00 3418840                    /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.0.0
7fcfbdb60000-7fcfbdb70000 r-xp 00000000 fe:00 3418842                    /usr/lib/x86_64-linux-gnu/libtasn1.so.3.1.16
7fcfbdb70000-7fcfbdd6f000 ---p 00010000 fe:00 3418842                    /usr/lib/x86_64-linux-gnu/libtasn1.so.3.1.16
7fcfbdd6f000-7fcfbdd70000 r--p 0000f000 fe:00 3418842                    /usr/lib/x86_64-linux-gnu/libtasn1.so.3.1.16
7fcfbdd70000-7fcfbdd71000 rw-p 00010000 fe:00 3418842                    /usr/lib/x86_64-linux-gnu/libtasn1.so.3.1.16
7fcfbdd71000-7fcfbdd93000 r-xp 00000000 fe:00 919309                     /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7fcfbdd93000-7fcfbdf92000 ---p 00022000 fe:00 919309                     /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7fcfbdf92000-7fcfbdf93000 r--p 00021000 fe:00 919309                     /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7fcfbdf93000-7fcfbdf94000 rw-p 00022000 fe:00 919309                     /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7fcfbdf94000-7fcfbdfaa000 r-xp 00000000 fe:00 919386                     /lib/x86_64-linux-gnu/libz.so.1.2.7
7fcfbdfaa000-7fcfbe1a9000 ---p 00016000 fe:00 919386                     /lib/x86_64-linux-gnu/libz.so.1.2.7
7fcfbe1a9000-7fcfbe1aa000 r--p 00015000 fe:00 919386                     /lib/x86_64-linux-gnu/libz.so.1.2.7
7fcfbe1aa000-7fcfbe1ab000 rw-p 00016000 fe:00 919386                     /lib/x86_64-linux-gnu/libz.so.1.2.7
7fcfbe1ab000-7fcfbe1b8000 r-xp 00000000 fe:00 919629                     /lib/x86_64-linux-gnu/libudev.so.0.13.0
7fcfbe1b8000-7fcfbe3b8000 ---p 0000d000 fe:00 919629                     /lib/x86_64-linux-gnu/libudev.so.0.13.0
7fcfbe3b8000-7fcfbe3b9000 r--p 0000d000 fe:00 919629                     /lib/x86_64-linux-gnu/libudev.so.0.13.0
7fcfbe3b9000-7fcfbe3ba000 rw-p 0000e000 fe:00 919629                     /lib/x86_64-linux-gnu/libudev.so.0.13.0
7fcfbe3ba000-7fcfbe43b000 r-xp 00000000 fe:00 924544                     /lib/x86_64-linux-gnu/libm-2.13.so
7fcfbe43b000-7fcfbe63a000 ---p 00081000 fe:00 924544                     /lib/x86_64-linux-gnu/libm-2.13.so
7fcfbe63a000-7fcfbe63b000 r--p 00080000 fe:00 924544                     /lib/x86_64-linux-gnu/libm-2.13.so
7fcfbe63b000-7fcfbe63c000 rw-p 00081000 fe:00 924544                     /lib/x86_64-linux-gnu/libm-2.13.so
7fcfbe63c000-7fcfbe678000 r-xp 00000000 fe:00 922972                     /lib/x86_64-linux-gnu/libpcre.so.3.13.1
7fcfbe678000-7fcfbe878000 ---p 0003c000 fe:00 922972                     /lib/x86_64-linux-gnu/libpcre.so.3.13.1
7fcfbe878000-7fcfbe879000 rw-p 0003c000 fe:00 922972                     /lib/x86_64-linux-gnu/libpcre.so.3.13.1
7fcfbe879000-7fcfbe88e000 r-xp 00000000 fe:00 919303                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fcfbe88e000-7fcfbea8e000 ---p 00015000 fe:00 919303                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fcfbea8e000-7fcfbea8f000 rw-p 00015000 fe:00 919303                     /lib/x86_64-linux-gnu/libgcc_s.so.1
7fcfbea8f000-7fcfbea91000 r-xp 00000000 fe:00 924535                     /lib/x86_64-linux-gnu/libdl-2.13.so
7fcfbea91000-7fcfbec91000 ---p 00002000 fe:00 924535                     /lib/x86_64-linux-gnu/libdl-2.13.so
7fcfbec91000-7fcfbec92000 r--p 00002000 fe:00 924535                     /lib/x86_64-linux-gnu/libdl-2.13.so
7fcfbec92000-7fcfbec93000 rw-p 00003000 fe:00 924535                     /lib/x86_64-linux-gnu/libdl-2.13.so
7fcfbec93000-7fcfbec95000 r-xp 00000000 fe:00 924530                     /lib/x86_64-linux-gnu/libutil-2.13.so
7fcfbec95000-7fcfbee94000 ---p 00002000 fe:00 924530                     /lib/x86_64-linux-gnu/libutil-2.13.so
7fcfbee94000-7fcfbee95000 r--p 00001000 fe:00 924530                     /lib/x86_64-linux-gnu/libutil-2.13.so
7fcfbee95000-7fcfbee96000 rw-p 00002000 fe:00 924530                     /lib/x86_64-linux-gnu/libutil-2.13.so
7fcfbee96000-7fcfbeead000 r-xp 00000000 fe:00 924531                     /lib/x86_64-linux-gnu/libpthread-2.13.so
7fcfbeead000-7fcfbf0ac000 ---p 00017000 fe:00 924531                     /lib/x86_64-linux-gnu/libpthread-2.13.so
7fcfbf0ac000-7fcfbf0ad000 r--p 00016000 fe:00 924531                     /lib/x86_64-linux-gnu/libpthread-2.13.so
7fcfbf0ad000-7fcfbf0ae000 rw-p 00017000 fe:00 924531                     /lib/x86_64-linux-gnu/libpthread-2.13.so
7fcfbf0ae000-7fcfbf0b2000 rw-p 00000000 00:00 0 
7fcfbf0b2000-7fcfbf0b9000 r-xp 00000000 fe:00 924540                     /lib/x86_64-linux-gnu/librt-2.13.so
7fcfbf0b9000-7fcfbf2b8000 ---p 00007000 fe:00 924540                     /lib/x86_64-linux-gnu/librt-2.13.so
7fcfbf2b8000-7fcfbf2b9000 r--p 00006000 fe:00 924540                     /lib/x86_64-linux-gnu/librt-2.13.so
7fcfbf2b9000-7fcfbf2ba000 rw-p 00007000 fe:00 924540                     /lib/x86_64-linux-gnu/librt-2.13.so
7fcfbf2ba000-7fcfbf2d8000 r-xp 00000000 fe:00 919334                     /lib/x86_64-linux-gnu/libselinux.so.1
7fcfbf2d8000-7fcfbf4d7000 ---p 0001e000 fe:00 919334                     /lib/x86_64-linux-gnu/libselinux.so.1
7fcfbf4d7000-7fcfbf4d8000 r--p 0001d000 fe:00 919334                     /lib/x86_64-linux-gnu/libselinux.so.1
7fcfbf4d8000-7fcfbf4d9000 rw-p 0001e000 fe:00 919334                     /lib/x86_64-linux-gnu/libselinux.so.1
7fcfbf4d9000-7fcfbf4da000 rw-p 00000000 00:00 0 
7fcfbf4da000-7fcfbf53b000 r-xp 00000000 fe:00 3420433                    /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0
7fcfbf53b000-7fcfbf73a000 ---p 00061000 fe:00 3420433                    /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0
7fcfbf73a000-7fcfbf73d000 r--p 00060000 fe:00 3420433                    /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0
7fcfbf73d000-7fcfbf73e000 rw-p 00063000 fe:00 3420433                    /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.2.0
7fcfbf73e000-7fcfbf7b8000 r-xp 00000000 fe:00 919632                     /lib/x86_64-linux-gnu/libgcrypt.so.11.7.0
7fcfbf7b8000-7fcfbf9b8000 ---p 0007a000 fe:00 919632                     /lib/x86_64-linux-gnu/libgcrypt.so.11.7.0
7fcfbf9b8000-7fcfbf9b9000 r--p 0007a000 fe:00 919632                     /lib/x86_64-linux-gnu/libgcrypt.so.11.7.0
7fcfbf9b9000-7fcfbf9bc000 rw-p 0007b000 fe:00 919632                     /lib/x86_64-linux-gnu/libgcrypt.so.11.7.0Aborted

$ valgrind ./a.out
==32414== Memcheck, a memory error detector
==32414== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==32414== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==32414== Command: ./a.out
==32414== 
==32414== Invalid free() / delete / delete[] / realloc()
==32414==    at 0x4C27D4E: free (vg_replace_malloc.c:427)
==32414==    by 0x4E8E188: virFree (viralloc.c:446)
==32414==    by 0x4EA2585: virResetError (virerror.c:328)
==32414==    by 0x4EA3CF5: virEventRegisterDefaultImpl (virevent.c:232)
==32414==    by 0x40076D: main (in /home/jesse/src/slamr-modules-domain-monitor/a.out)
==32414==  Address 0xad028f0 is 1,024 bytes inside a block of size 2,032 alloc'd
==32414==    at 0x4C272B8: calloc (vg_replace_malloc.c:566)
==32414==    by 0x5426F88: g_malloc0 (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==32414==    by 0x53F3CA8: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==32414==    by 0x543B48C: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==32414==    by 0x543ECCA: g_string_sized_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==32414==    by 0x543F2F2: g_string_new (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4)
==32414==    by 0x400764: main (in /home/jesse/src/slamr-modules-domain-monitor/a.out)
==32414== 
==32414== Invalid free() / delete / delete[] / realloc()
==32414==    at 0x4C27D4E: free (vg_replace_malloc.c:427)
==32414==    by 0x4E8E188: virFree (viralloc.c:446)
==32414==    by 0x4EA258E: virResetError (virerror.c:329)
==32414==    by 0x4EA3CF5: virEventRegisterDefaultImpl (virevent.c:232)
==32414==    by 0x40076D: main (in /home/jesse/src/slamr-modules-domain-monitor/a.out)
==32414==  Address 0x32 is not stack'd, malloc'd or (recently) free'd
==32414== 
==32414== 
==32414== HEAP SUMMARY:
==32414==     in use at exit: 84,750 bytes in 121 blocks
==32414==   total heap usage: 191 allocs, 72 frees, 199,464 bytes allocated
==32414== 
==32414== LEAK SUMMARY:
==32414==    definitely lost: 0 bytes in 0 blocks
==32414==    indirectly lost: 0 bytes in 0 blocks
==32414==      possibly lost: 2,365 bytes in 23 blocks
==32414==    still reachable: 82,385 bytes in 98 blocks
==32414==         suppressed: 0 bytes in 0 blocks
==32414== Rerun with --leak-check=full to see details of leaked memory
==32414== 
==32414== For counts of detected and suppressed errors, rerun with: -v
==32414== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 18 from 6)

Expected results:

No error

Additional info:
Comment 1 Jesse Cook 2013-05-08 20:54:08 EDT
I should clarify. This happens both when linking to library compiled from source and one installed by Debian Wheezy.

This is the minimal example. It was discovered during the rewrite of domain monitoring code as part of a migration to Debian Wheezy that is part of a larger project.
Comment 2 Daniel Berrange 2013-05-09 03:54:43 EDT
Your code is not compliant with the libvirt API requirements that virInitialize be called

http://libvirt.org/html/libvirt-libvirt.html#virInitialize

Since you're not calling virConnectOpen as your first API call, you must explicitly invoke virInitialize.
Comment 3 Jesse Cook 2013-05-09 11:02:06 EDT
Thank you. I will submit a patch for libvirt/examples/domain-events/event-c. The example program makes a call to virEventRegisterDefaultImpl before calling virConnectOpen without a call to virInitialize. Interestingly enough, the example code works.  However, once you introduce a call to g_string_new it breaks. This can result in unintentional misuse of the API.
Comment 4 Daniel Berrange 2013-05-09 11:06:08 EDT
It might be worth making  virEventRegisterDefaultImpl implicitly call virInitialize to avoid people hitting the bug, as we do for virConnectOpen.
Comment 5 Cole Robinson 2016-04-09 19:09:41 EDT
I see the example was updated, so I think that counts as fixed

Note You need to log in before you can comment on or make changes to this bug.