[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] PATCH: Fix DBus thread safety



On Wed, Feb 18, 2009 at 06:56:08PM +0100, Jim Meyering wrote:
> "Daniel P. Berrange" <berrange redhat com> wrote:
> > We are using DBus from multiple threads in libvirtd. We are not calling
> > dbus_threads_init_default().  Very bad things result. Happy-crashy-daemon
> >
> > This patch fixes that, and also stops DBus messing around with SIGPIPE and
> > also stops it calling exit() when the bus disconnects, so we can actually
> > see the error & continue with life.
> 
> These all look fine.
> I can attest to having stared hard at dbus' SIGPIPE-handling code
> (and asking why, oh why, a *library* handles a signal, by default)
> so am glad to see it turned off here.
> 
> However, now there are 3 dbus-init-related lines in each of those files,
> not counting the slightly-separated *_set_exit_on_disconnect call.
> It'd be nice to encapsulate those, or at least to add a comment
> before each saying to keep them in sync.
> 
> Hmm. actually there are four calls in each place:
> 
>   dbus_connection_set_change_sigpipe(FALSE);
>   dbus_threads_init_default();
>   dbus_error_init
>   ... = dbus_bus_get(...
> 
> Only the last one can fail.
> 
> For the record, are these crashes easy to reproduce?

Sometimes. When running on an SMP system, if you have the libvirtd
running as root, and then as non-root while logged into GNOME, run
'for i in `seq 1 100` ; do virsh -c qemu:///system list ; done'
it will probably fail somewhere between the 10 and 30 mark. 
If you run under GDB it'll often not fail till the 70 mark. And it
never fails under valgrind, because valgrind doesn't allow true
concurrency of the threads. Sometimes it would SEGV, other times
it would just exit due to RPC message corruption.

Daniel
-- 
|: Red Hat, Engineering, London   -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 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]