[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-dbus
Subject:    Out-of-memory error when using multiple threads
From:       "Olivier Hochreutiner" <olivier.hochreutiner () gmail ! com>
Date:       2007-12-28 17:20:34
Message-ID: f967eaa30712280920h86ad799u94c99598d7872e66 () mail ! gmail ! com
[Download RAW message or body]

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

["backtrace.txt" (text/plain)]

#0  protected_change_timeout (connection=0x80521a0, timeout=0x805a4c8, \
add_function=0xb7c934d4 <_dbus_timeout_list_add_timeout>, remove_function=0, \
toggle_function=0, enabled=0) at dbus-connection.c:807 #1  0xb7c5e50b in \
_dbus_connection_add_timeout_unlocked (connection=0x80521a0, timeout=0x805a4c8) at \
dbus-connection.c:826 #2  0xb7c5e663 in _dbus_connection_attach_pending_call_unlocked \
(connection=0x80521a0, pending=0x805a480) at dbus-connection.c:886 #3  0xb7c63cf4 in \
dbus_connection_send_with_reply (connection=0x80521a0, message=0x805a5d8, \
pending_return=0xb240a15c, timeout_milliseconds=-1) at dbus-connection.c:3173 #4  \
0xb7c6407a in dbus_connection_send_with_reply_and_block (connection=0x80521a0, \
message=0x805a5d8, timeout_milliseconds=-1, error=0xb240a200) at \
dbus-connection.c:3255 #5  0xb7c5d240 in send_no_return_values (connection=0x80521a0, \
msg=0x805a5d8, error=0xb240a200) at dbus-bus.c:1360 #6  0xb7c5d438 in \
dbus_bus_add_match (connection=0x80521a0, rule=0x805c12c \
"type='signal',interface='org.freedesktop.DBus.Introspectable',path='/org/freedesktop/DBus/Examples/Echo'", \
error=0xb240a200) at dbus-bus.c:1486 #7  0xb7f8f14e in DBus::Connection::add_match \
(this=0xb240a35c, rule=0x805c12c \
"type='signal',interface='org.freedesktop.DBus.Introspectable',path='/org/freedesktop/DBus/Examples/Echo'") \
at connection.cpp:309 #8  0xb7f85a78 in DBus::ObjectProxy::register_obj \
(this=0xb240a358) at object.cpp:294 #9  0xb7f87279 in ObjectProxy (this=0xb240a358, \
__vtt_parm=0x804e064, conn=@0xbfed1c38, path=@0xb240a2e0, service=0x804df70 \
"org.freedesktop.DBus.Examples.Echo") at object.cpp:274 #10 0x0804ac17 in EchoClient \
(this=0xb240a318, connection=@0xbfed1c38, path=0x804df94 \
"/org/freedesktop/DBus/Examples/Echo", name=0x804df70 \
"org.freedesktop.DBus.Examples.Echo") at echo-client.cpp:16 #11 0x0804ad2f in \
greeter_thread (arg=0xbfed1c38) at echo-client.cpp:37 #12 0xb7f4946b in start_thread \
() from /lib/tls/i686/cmov/libpthread.so.0 #13 0xb7da96de in clone () from \
/lib/tls/i686/cmov/libc.so.6



_______________________________________________
dbus mailing list
dbus@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dbus


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic