<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Arial; font-size: 12pt; color: #000000'><br>----- "Matthias Bolte" <matthias.bolte@googlemail.com> wrote:
<br>> 2010/1/10  <pspreadborough@comcast.net>:<br>> ><br>> > ----- "Matthias Bolte" <matthias.bolte@googlemail.com> wrote:<br>> ><br>> >> 2010/1/10  <pspreadborough@comcast.net>:<br>> >> ><br>> >> > Hello,<br>> >> ><br>> >> > I have been trying to use the domain event C code example but<br>> >> > unfortunately it segfaults (signal 11) every time I run it:<br>> >> ><br>> >> > [root@Spring events-c]# ./event-test<br>> >> > myEventAddHandleFunc:221: Add handle 5 1 0xf081a0 0x8f727f8<br>> >> > myEventAddHandleFunc:221: Add handle 7 1 0xf09990 0x8f727f8<br>> >> > myEventAddHandleFunc:221: Add handle 8 1 0xed7940 0x8f727f8<br>> >> > myEventAddTimeoutFunc:251: Adding Timeout -1 0xedefa0 0x8f727f8<br>> >> > myEventAddHandleFunc:221: Add handle 11 1 0xed7940 0x8f727f8<br>> >> > myEventAddTimeoutFunc:251: Adding Timeout -1 0xedefa0 0x8f727f8<br>> >> > main:322 :: Registering domain event cbs<br>> >> > Segmentation fault (core dumped)<br>> >> ><br>> >> >  Core was generated by<br>> >> ><br>> >> `/root/libvirt-0.7.5/examples/domain-events/events-c/.libs/lt-event-test'.<br>> >> > Program terminated with signal 11, Segmentation fault.<br>> >> > [New process 21806]<br>> >> > [New process 21822]<br>> >> > #0  remoteDomainEventQueueFlush (timer=-1, opaque=0x8f727f8) at<br>> >> > remote/remote_driver.c:8720<br>> >> > 8720        tempQueue.count = priv->domainEvents->count;<br>> >> > (gdb) bt<br>> >> > #0  remoteDomainEventQueueFlush (timer=-1, opaque=0x8f727f8) at<br>> >> > remote/remote_driver.c:8720<br>> >> > #1  0x080490d3 in main (argc=Cannot access memory at address 0x1<br>> >> > ) at event-test.c:347<br>> >> ><br>> >> > The stack looks corrupted so I'm doubtful that this trace if of much<br>> >> value.<br>> >> > I have built<br>> >> > and installed libvirt-0.7.5 and it and it's tools seem to be<br>> >> operating<br>> >> > correctly.<br>> >><br>> >> I tried the event-test with libvirt-0.7.5 and QEMU/Xen and both are<br>> >> working as expected. No segfaults.<br>> >><br>> >> Could you inspect the values of priv and priv->domainEvents in GDB<br>> >> using 'p priv' to see if they are NULL and try to dereference them in<br>> >> GDB using 'p *priv' to see if they point to valid memory areas?<br>> >><br>> >> Yes the backtrace looks corrupted. If there is stack/heap corruption<br>> >> involved valgrind may reveal it, so try to run the event-test in<br>> >> valgrind and see if that gives any hints.<br>> >><br>> >> You can also try the GIT version of libvirt. There was a invalid free<br>> >> call (resulting in heap corruption) in the node device code fixed<br>> >> after the 0.7.5 release. But that should have no effect on the<br>> >> event-test.<br>> >><br>> >> Matthias<br>> ><br>> > Matthias,<br>> ><br>> > priv->domainEvents is NULL, here's the gdb output:<br>> <br>> This explains the segfault. The next question is, why is it NULL?<br>> <br>> > (gdb) p *priv<br>> > $1 = {lock = {lock = {__data = {__lock = 1, __count = 0, __owner = 21806, __kind = 0, __nusers = 1, {__spins = 0, __list = {<br>> >            __next = 0x0}}}, __size = "\001\000\000\000\000\000\000\000.U\000\000\000\000\000\000\001\000\000\000\000\000\000",<br>> >      __align = 1}}, sock = 150469168, watch = 3, pid = 4, uses_tls = 1982791681, is_secure = 1815048801, session = 0x782f6269,<br>> <br>> Seeing uses_tls and is_secure being large numbers and knowing that<br>> both are used as boolean values in the code and should have values of<br>> 0 or 1 make me think that priv points to already freed memory here.<br>> <br>> >  type = 0x2f646e65 <Address 0x2f646e65 out of bounds>, counter = 1684956536, localUses = 1668248365,<br>> >  hostname = 0x74656b <Address 0x74656b out of bounds>, debugLog = 0x0, saslconn = 0x0, saslDecoded = 0x0, saslDecodedLength = 0,<br>> <br>> type and hostname are char pointers, but the seem to point into<br>> nowhere, confirms that this is either freed memory or priv itself got<br>> overwritten due to heap corruption.<br>> <br>> >  saslDecodedOffset = 0, saslEncoded = 0x0, saslEncodedLength = 0, saslEncodedOffset = 0,<br>> >  buffer = '\0' <repeats 68 times>, "n\000\000\000\001\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\001\000\000\000\001\000\000\000\000\000\000\000\001\000\000\000\bQ�\b����\030\034�\b\000\000\000\000�\033�\b\001\000\000\000\002\000\000\000�\033�\b\000\000\000\000\025|�\000\a", '\0' <repeats 11 times>, "X\000�\b", '\0' <repeats 12 times>, "\021\000\000\000\002\000\000\000P��\b\000\000\000\000\021", '\0' <repeats 15 times>, "\021\000\000\0008\036�\b\f\000\000\000\020\000\000\000\021\000\000\000\a\000\000\000\b\000\000\000\t\000\000\000\021\000\000\000\002\000\000\000\230\034�\b\000\000\000\000A\000\000\000\003\000\000\000\001\000\000\000\001\000"..., bufferLength = 0,<br>> >  bufferOffset = 0, callbackList = 0x0, domainEvents = 0x0, eventFlushTimer = 0, domainEventDispatching = 1, wakeupSendFD = 0,<br>> >  wakeupReadFD = 0, waitDispatch = 0x0, streams = 0x0}<br>> ><br>> > I'll try a run with valgrind and post the results.<br>> ><br>> > Pete<br>> ><br>> <br>> Could you test the Python version of this example found in<br>> examples/domain-events/events-python/event-test.py? Does this work?<br>> <br>> Otherwise lets see if valgrind gives any hints.<br>> <br>> Matthias<br>><br><br>Matthias,<br><br>I have built the latest git image and run it through valgrind, here's the valgrind output:<br><br>[root@Spring .libs]# valgrind  -v ./event-test xen:///<br>==19881== Memcheck, a memory error detector.<br>==19881== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.<br>==19881== Using LibVEX rev 1658, a library for dynamic binary translation.<br>==19881== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.<br>==19881== Using valgrind-3.2.1, a dynamic binary instrumentation framework.<br>==19881== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.<br>==19881== <br>--19881-- Command line<br>--19881--    ./event-test<br>--19881--    xen:///<br>--19881-- Startup, with flags:<br>--19881--    -v<br>--19881-- Contents of /proc/version:<br>--19881--   Linux version 2.6.18-164.10.1.el5xen (mockbuild@builder16.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Thu Jan 7 21:14:48 EST 2010<br>--19881-- Arch and hwcaps: X86, x86-sse1-sse2<br>--19881-- Valgrind library directory: /usr/lib/valgrind<br>--19881-- Reading syms from /lib/ld-2.5.so (0x163000)<br>--19881-- Reading syms from /root/libvirt/libvirt/examples/domain-events/events-c/.libs/event-test (0x8048000)<br>--19881-- Reading syms from /usr/lib/valgrind/x86-linux/memcheck (0x38000000)<br>--19881--    object doesn't have a dynamic symbol table<br>--19881-- Reading suppressions file: /usr/lib/valgrind/default.supp<br>--19881-- REDIR: 0x178790 (index) redirected to 0x38027D0F (vgPlain_x86_linux_REDIR_FOR_index)<br>--19881-- Reading syms from /usr/lib/valgrind/x86-linux/vgpreload_core.so (0x4001000)<br>--19881-- Reading syms from /usr/lib/valgrind/x86-linux/vgpreload_memcheck.so (0x4003000)<br>==19881== WARNING: new redirection conflicts with existing -- ignoring it<br>--19881--     new: 0x00178790 (index     ) R-> 0x04006080 index<br>--19881-- REDIR: 0x178930 (strlen) redirected to 0x4006250 (strlen)<br>--19881-- Reading syms from /usr/local/lib/libvirt.so.0.7.5 (0x4009000)<br>--19881-- Reading syms from /usr/lib/libxml2.so.2.6.26 (0x6254000)<br>--19881--    object doesn't have a symbol table<br>--19881-- Reading syms from /usr/lib/libz.so.1.2.3 (0xCD2000)<br>--19881--    object doesn't have a symbol table<br>--19881-- Reading syms from /lib/libm-2.5.so (0x413B000)<br>--19881-- Reading syms from /usr/lib/libgnutls.so.13.0.6 (0x670D000)<br>--19881--    object doesn't have a symbol table<br>--19881-- Reading syms from /usr/lib/libgcrypt.so.11.5.2 (0x6590000)<br>--19881--    object doesn't have a symbol table<br>--19881-- Reading syms from /usr/lib/libsasl2.so.2.0.22 (0x6536000)<br>--19881--    object doesn't have a symbol table<br>--19881-- Reading syms from /usr/lib/libxenstore.so.3.0.0 (0x4162000)<br>--19881--    object doesn't have a symbol table<br>--19881-- Reading syms from /lib/libpthread-2.5.so (0x416A000)<br>--19881-- Reading syms from /lib/libc-2.5.so (0x4183000)<br>--19881-- Reading syms from /lib/libdl-2.5.so (0xCA7000)<br>--19881-- Reading syms from /usr/lib/libgpg-error.so.0.3.0 (0xB28000)<br>--19881--    object doesn't have a symbol table<br>--19881-- Reading syms from /lib/libresolv-2.5.so (0x26E000)<br>--19881-- Reading syms from /lib/libcrypt-2.5.so (0x64CE000)<br>--19881-- REDIR: 0x41F42D0 (memset) redirected to 0x4006540 (memset)<br>--19881-- REDIR: 0x41F47C0 (memcpy) redirected to 0x4006C20 (memcpy)<br>--19881-- REDIR: 0x41F3430 (rindex) redirected to 0x4005F60 (rindex)<br>--19881-- REDIR: 0x41F3090 (strlen) redirected to 0x4006230 (strlen)<br>--19881-- REDIR: 0x41EED20 (malloc) redirected to 0x400533B (malloc)<br>--19881-- REDIR: 0x41F2B30 (strcmp) redirected to 0x4006300 (strcmp)<br>--19881-- REDIR: 0x41EE9E0 (calloc) redirected to 0x4004668 (calloc)<br>--19881-- REDIR: 0x41F3DD0 (memchr) redirected to 0x4006420 (memchr)<br>--19881-- REDIR: 0x41EC980 (free) redirected to 0x4004F55 (free)<br>--19881-- REDIR: 0x41EF190 (realloc) redirected to 0x40053EA (realloc)<br>==19881== Warning: noted but unhandled ioctl 0x305000 with no size/direction hints<br>==19881==    This could cause spurious value errors to appear.<br>==19881==    See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.<br>==19881== Warning: noted but unhandled ioctl 0x305000 with no size/direction hints<br>==19881==    This could cause spurious value errors to appear.<br>==19881==    See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.<br>==19881== Warning: noted but unhandled ioctl 0x305000 with no size/direction hints<br>==19881==    This could cause spurious value errors to appear.<br>==19881==    See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.<br>--19881-- REDIR: 0x41F29C0 (index) redirected to 0x4006050 (index)<br>--19881-- REDIR: 0x41F3280 (strncmp) redirected to 0x4006290 (strncmp)<br>--19881-- REDIR: 0x41F44C0 (stpcpy) redirected to 0x40068D0 (stpcpy)<br>--19881-- REDIR: 0x41F3140 (strnlen) redirected to 0x4006200 (strnlen)<br>--19881-- REDIR: 0x41F3380 (strncpy) redirected to 0x4006DA0 (strncpy)<br>--19881-- REDIR: 0x41F2BA0 (strcpy) redirected to 0x40069B0 (strcpy)<br>myEventAddHandleFunc:221: Add handle 5 1 0x40ad4a0 0x42d6188<br>myEventAddHandleFunc:221: Add handle 7 1 0x40aec90 0x42d6188<br>Allocating domainEvents:0x43bea68<br>myEventAddHandleFunc:221: Add handle 8 1 0x407c940 0x42d6188<br>myEventAddTimeoutFunc:251: Adding Timeout -1 0x4083fe0 0x42d6188<br>Allocating domainEvents:0x4e8c320<br>myEventAddHandleFunc:221: Add handle 11 1 0x407c940 0x42d6188<br>myEventAddTimeoutFunc:251: Adding Timeout -1 0x4083fe0 0x42d6188<br>main:322 :: Registering domain event cbs<br>poll<br>==19881== Invalid read of size 4<br>==19881==    at 0x4084011: remoteDomainEventQueueFlush (remote_driver.c:8722)<br>==19881==    by 0x80490C2: main (event-test.c:341)<br>==19881==  Address 0x0 is not stack'd, malloc'd or (recently) free'd<br>==19881== <br>==19881== Process terminating with default action of signal 11 (SIGSEGV)<br>==19881==  Access not within mapped region at address 0x0<br>==19881==    at 0x4084011: remoteDomainEventQueueFlush (remote_driver.c:8722)<br>==19881==    by 0x80490C2: main (event-test.c:341)<br>==19881== <br>==19881== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 30 from 1)<br>==19881== <br>==19881== 1 errors in context 1 of 1:<br>==19881== Invalid read of size 4<br>==19881==    at 0x4084011: remoteDomainEventQueueFlush (remote_driver.c:8722)<br>==19881==    by 0x80490C2: main (event-test.c:341)<br>==19881==  Address 0x0 is not stack'd, malloc'd or (recently) free'd<br>--19881-- <br>--19881-- supp:   30 Fedora-Core-6-hack3-ld25<br>==19881== <br>==19881== IN SUMMARY: 1 errors from 1 contexts (suppressed: 30 from 1)<br>==19881== <br>==19881== malloc/free: in use at exit: 590,340 bytes in 686 blocks.<br>==19881== malloc/free: 1,695 allocs, 1,009 frees, 1,700,423 bytes allocated.<br>==19881== <br>==19881== searching for pointers to 686 not-freed blocks.<br>==19881== checked 11,495,892 bytes.<br>==19881== <br>==19881== LEAK SUMMARY:<br>==19881==    definitely lost: 0 bytes in 0 blocks.<br>==19881==      possibly lost: 136 bytes in 1 blocks.<br>==19881==    still reachable: 590,204 bytes in 685 blocks.<br>==19881==         suppressed: 0 bytes in 0 blocks.<br>==19881== Reachable blocks (those to which a pointer was found) are not shown.<br>==19881== To see them, rerun with: --show-reachable=yes<br>--19881--  memcheck: sanity checks: 3 cheap, 1 expensive<br>--19881--  memcheck: auxmaps: 0 auxmap entries (0k, 0M) in use<br>--19881--  memcheck: auxmaps: 0 searches, 0 comparisons<br>--19881--  memcheck: SMs: n_issued      = 36 (576k, 0M)<br>--19881--  memcheck: SMs: n_deissued    = 0 (0k, 0M)<br>--19881--  memcheck: SMs: max_noaccess  = 65535 (1048560k, 1023M)<br>--19881--  memcheck: SMs: max_undefined = 0 (0k, 0M)<br>--19881--  memcheck: SMs: max_defined   = 244 (3904k, 3M)<br>--19881--  memcheck: SMs: max_non_DSM   = 36 (576k, 0M)<br>--19881--  memcheck: max sec V bit nodes:    115 (5k, 0M)<br>--19881--  memcheck: set_sec_vbits8 calls: 679 (new: 115, updates: 564)<br>--19881--  memcheck: max shadow mem size:   885k, 0M<br>--19881-- translate:            fast SP updates identified: 7,064 ( 89.2%)<br>--19881-- translate:   generic_known SP updates identified: 543 (  6.8%)<br>--19881-- translate: generic_unknown SP updates identified: 304 (  3.8%)<br>--19881--     tt/tc: 13,590 tt lookups requiring 14,331 probes<br>--19881--     tt/tc: 13,590 fast-cache updates, 3 flushes<br>--19881--  transtab: new        6,511 (139,232 -> 2,275,366; ratio 163:10) [0 scs]<br>--19881--  transtab: dumped     0 (0 -> ??)<br>--19881--  transtab: discarded  8 (187 -> ??)<br>--19881-- scheduler: 374,982 jumps (bb entries).<br>--19881-- scheduler: 3/10,454 major/minor sched events.<br>--19881--    sanity: 4 cheap, 1 expensive checks.<br>--19881--    exectx: 30,011 lists, 566 contexts (avg 0 per list)<br>--19881--    exectx: 2,732 searches, 2,171 full compares (794 per 1000)<br>--19881--    exectx: 0 cmp2, 67 cmp4, 0 cmpAll<br>Killed<br>[root@Spring .libs]# <br><br>I tried the python version and did have some success, but not 100% since I didn't <br>see events for pausing the VM:<br><br>[root@Spring events-python]# python event-test.py xen:///<br>Using uri:xen:///<br><br>myDomainEventCallback2 EVENT: Domain vm-full-1(1) Started 0<br>myDomainEventCallback1 EVENT: Domain vm-full-1(1) Started 0<br><br>I noticed that the the C version looks in one place for the libvirt socket and the<br>python version in a different place, I don't know if this is significant or not?<br>I tweaked the /etc/libvirt/libvirtd.conf file to alter the location.<br><br>C: /usr/local/var/run/libvirt<br>python: /var/run/libvirt/<br><br>Regards,<br><br>Pete<br><br><br></div></body></html>