[libvirt] segment fault from libvirtmod

Eric Blake eblake at redhat.com
Mon Feb 6 22:53:26 UTC 2012


On 02/06/2012 07:59 AM, Michal Privoznik wrote:

> Running git bisect showed it was caused by
> c700613b8d463212d142c97108b7a2352e23e559. However, I think it only
> exposed the design problem we are facing here.
> 
> IMHO problem is when an application tries to call virConnectOpen() (or
> virConnectOpenAuth()) from two concurrent threads. This is what will happen:
> 
> 1st thread:
>   call virConnectOpen();
>   global variable @initialized == zero; thus virInitialize() is called,
> error object is set up (via virErrorInitialize()) which is thread local
> variable. However, @initialized is set to 1 in the first place.
> 
> 2nd thread:
>   call virConnectOpen() as well;
>   @initialized is already set, therefore no thread local variable is set
> and any error report will fail.

Ouch - I agree with your analysis of a thread-safety issue.  I think we
can fix it by making virInitialize() delegate most of its work to a
virOnce() initialization function.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120206/7d60a013/attachment-0001.sig>


More information about the libvir-list mailing list