Out-of-memory error when using multiple threads

Olivier Hochreutiner olivier.hochreutiner at gmail.com
Fri Dec 28 09:20:34 PST 2007


Hi again,

As promised in my previous post here is a description of an OOM error
that occurs in libdbus-1 in a multithreaded environment.

The bug can be reproduced easily with the 'echo-client-mt' example of
D-Bus C++ binding. For recall this program creates 16 threads. Each
thread does the same method call 100 times in a loop (method calls are
done with dbus_connection_send_with_reply_and_block()), and the main
thread is the dispatcher thread.
When echo-client-mt is run it dies after a few method calls with an
OOM error returned by dbus_connection_send_with_reply_and_block(). I
backtraced the error and I found it happens in
protected_change_timeout() (see attached backtrace). When a thread
reaches this point it sets connection->timeouts to NULL and then drops
the connection lock to do the callbacks. If in the meantime another
thread reach the same point it will find a NULL connection->timeouts
and fail.
I guess the problem can be fixed by adding a separate lock to protect
the timeouts field of DBusConnection. What do you think ?

Hapy new year again,

Olivier
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: backtrace.txt
Url: http://lists.freedesktop.org/archives/dbus/attachments/20071228/3cc76e97/attachment.txt 


More information about the dbus mailing list