<html><body>
<p>DV,<br>
<br>
    Its not mirrored to RH yet, I am working on it. In the meantime, here is the description of the defect.<br>
<br>
********************************************<br>
<tt>virInitialize leads to segfault when unloading libvirt-cim providers.<br>
<br>
Contact Information = Sharad Mishra/</tt><a href="mailto:snmishra@us.ibm.com"><tt><font color="#0055AA">snmishra@us.ibm.com</font></tt></a><tt>,  <br>
<br>
---uname output---<br>
Linux elm3b193.beaverton.ibm.com 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT<br>
2010 x86_64 x86_64 x86_64 GNU/Linux<br>
<br>
Machine Type = IBM system x blade, machine type - 8853, model - MC1 <br>
<br>
---Debugger---<br>
A debugger is not configured<br>
<br>
---Steps to Reproduce---<br>
 1. Install libvirt and libvirt-cim<br>
2 start libvirtd<br>
3. start tog-pegasus<br>
4. run wbemcli command to enum instance on KVM_ComputerSystem class. This is<br>
just a way to load the provider to memory. All  we need to do is run<br>
virConnectOpen() and virConnectClose() in this provider. So in this step all<br>
that is required is for virConnectOpen and virConnectClose to run.<br>
5. Stop tog-pegasus. <br>
<br>
A core is gererated.<br>
<br>
---System Management Component Data--- <br>
Userspace tool common name: libvirt/libvirt-cim/tog-pegasus <br>
<br>
System management type: IMM <br>
<br>
The userspace tool has the following bit modes: 64 <br>
<br>
Userspace rpm: libvirt-0.6.3-33.el5,  libvirt-cim-0.5.14-1 and<br>
tog-pegasus-2.9.2-2.el5 <br>
<br>
Userspace tool obtained from project website:  na <br>
<br>
*Additional Instructions for Sharad Mishra/</tt><a href="mailto:snmishra@us.ibm.com"><tt><font color="#0055AA">snmishra@us.ibm.com</font></tt></a><tt>, : <br>
-Post a private note with access information to the machine that the bug is<br>
occuring on.<br>
-Attach ltrace and strace of userspace application.<br>
-Attach screen shoot of System Managment Utility<br>
<br>
<br>
Here is the gist of investigation done so far ---<br>
<br>
Here is the gist of his investigation -<br>
<br>
<br>
I've looked into the libvirt source code and the reason for issues with the<br>
unload of libvirt-cim providers is there (and cimprovider -r forces an unload,<br>
just as cimserver shutdown does).<br>
<br>
virConnectOpen() does call virInitialize() which then will initialize the<br>
gcrypt library after initializes the thread setup ->virThreadInitialize(),<br>
creates the error reporting structure ->virErrorInitialize() and initialize a<br>
random number generator ->virRandomInitialize().<br>
<br>
The issue is hidden in virErrorInitialize(). It calls virErrorInitialize()<br>
which uses the wrapper function virThreadLocalInit(&virLastErr,<br>
virLastErrFreeData);.<br>
virThreadLocalInit() calls pthread_create() with a destructor function<br>
(virLastErrFreeData()) which will be called on thread exits.<br>
<br>
Trouble here is that pthread_key_delete() is never called in libvirt, but next<br>
time the system runs through the key list and libvirt has been unloaded the<br>
system will jump to an already unloaded function (the pointer were<br>
virLastErrFreeData() was loaded formerly) and consequently crash the process.<br>
<br>
Fixing this will not be easy, but a start would be a libvirt function on its<br>
externalize interface that allows cleanup short before library unload, or<br>
alternatively libvirt does the thread key delete on library unload.<br>
<br>
<br>
Trace output from gdb -<br>
<br>
/var/log/messages: <br>
Aug  6 11:35:58 SYX-e41f13fe5558 cimserver[21602]: OpenPegasus stopped.<br>
Aug  6 11:35:59 SYX-e41f13fe5558 kernel: cimserver[21376]: segfault at<br>
00002aaaab165f00 rip 00002aaaab165f00 rsp 00000000457d40b8 error 14<br>
<br>
call stack trace:<br>
command: gdb -batch -x /tmp/gdb.27236.cmd /usr/sbin/cimserver<br>
/var/log/core/core.25567<br>
time:    Sat Aug  6 11:35:59 UTC 2011<br>
stdout/stderr:<br>
-----------------------------------------------------------------<br>
[New Thread 25567]<br>
Core was generated by `/usr/sbin/cimserver'.<br>
Program terminated with signal 11, Segmentation fault.<br>
#0  0x00002aaaab4f6f00 in ?? ()<br>
#0  0x00002aaaab4f6f00 in ?? ()<br>
#1  0x00002ab4fb3c6ad9 in __nptl_deallocate_tsd () from /lib64/libpthread.so.0<br>
#2  0x00002ab4fb3c774b in start_thread () from /lib64/libpthread.so.0<br>
#3  0x00002ab4fc07af6d in clone () from /lib64/libc.so.6<br>
-----------------------------------------------------------------<br>
 exit_code=0<br>
-----------------------------------------------------------------</tt><br>
<br>
Regards,<br>
Sharad Mishra<br>
Open Virtualization<br>
Linux Technology Center<br>
IBM<br>
<br>
<tt>libvirt-cim-bounces@redhat.com wrote on 08/30/2011 01:43:06 AM:<br>
<br>
> Daniel Veillard <veillard@redhat.com> </tt><br>
<tt>> Sent by: libvirt-cim-bounces@redhat.com<br>
> </tt><br>
<tt>> 08/30/11 01:43 AM</tt><br>
<tt>> <br>
> Please respond to<br>
> veillard@redhat.com; Please respond to<br>
> List for discussion and development of libvirt CIM <libvirt-cim@redhat.com></tt><br>
<tt>> <br>
> To</tt><br>
<tt>> <br>
> List for discussion and development of libvirt CIM <libvirt-cim@redhat.com></tt><br>
<tt>> <br>
> cc</tt><br>
<tt>> <br>
> Subject</tt><br>
<tt>> <br>
> Re: [Libvirt-cim] [PATCH] DO NOT PUSH UPSTREAM</tt><br>
<tt>> <br>
> On Fri, Aug 26, 2011 at 05:38:29PM -0000, Sharad Mishra wrote:<br>
> > # HG changeset patch<br>
> > # User Sharad Mishra <snmishra@us.ibm.com><br>
> > # Date 1314380301 25200<br>
> > # Node ID 73e7bb11410f3c10d3b0b61678531314262f09b7<br>
> > # Parent  2984ede9c082bab48b3494ef4b9f5561fadef2ad<br>
> > DO NOT PUSH UPSTREAM<br>
> > <br>
> > This is the workaround that was given to zGryphon<br>
> > team to prevent unloading of idle providers.<br>
> > There is a bug in libvirt that needs to be fixed.<br>
> > That fix will be the actual fix for this problem<br>
> > that cause segfault when those providers are unloaded<br>
> > that make a call to virConnectOpen.<br>
> <br>
>   I'm curious about the libvirt bug, which one is it ?<br>
> <br>
> Daniel<br>
> <br>
> -- <br>
> Daniel Veillard      | libxml Gnome XML XSLT toolkit  <a href="http://xmlsoft.org/">http://xmlsoft.org/</a><br>
> daniel@veillard.com  | Rpmfind RPM search engine <a href="http://rpmfind.net/">http://rpmfind.net/</a><br>
> <a href="http://veillard.com/">http://veillard.com/</a> | virtualization library  <a href="http://libvirt.org/">http://libvirt.org/</a><br>
> <br>
> _______________________________________________<br>
> Libvirt-cim mailing list<br>
> Libvirt-cim@redhat.com<br>
> <a href="https://www.redhat.com/mailman/listinfo/libvirt-cim">https://www.redhat.com/mailman/listinfo/libvirt-cim</a><br>
</tt></body></html>