Out-of-memory error when using multiple threads

Havoc Pennington hp at redhat.com
Sat Dec 29 06:01:46 PST 2007


Hi,

Olivier Hochreutiner wrote:
> 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 ?
> 

Is this the same as the "Phantom Out of Memory error" problem here:
http://lists.freedesktop.org/archives/dbus/2007-July/thread.html#8144

Another lock is expensive and complex, it would be better to avoid it if 
we can - the earlier thread has a few suggested alternatives.

Havoc




More information about the dbus mailing list