Review Request: Workaround for non-thread-safety of QDBusConnection

Thiago Macieira thiago at kde.org
Thu May 27 21:46:58 BST 2010


Em Quinta-feira 27. Maio 2010, às 16.43.20, Lubos Lunak escreveu:
>  If this is an important issue to fix, what is the patch and the problem 
> (=something specific) it fixes?

The patch is attached to the bugzilla report that Sebastian linked to.

It can't be applied to the current 1.2 tree because it contains a behaviour 
change in one of the basic event-loop integration callbacks.

The issue in question is that, when libdbus-1 needs to call the callback for 
enabling, disabling or toggling timers, or socket notifiers (DBusTimeout and 
DBusWatch in libdbus-1 parlance), it needs to drop the locks. It's standard 
procedure: you're calling out to user code, you drop all locks you have in 
place, because the user may do strange things and recurse back to you.

The problem is that, if we drop the locks, then a recursion may change the 
pointers in the structures that were being modified (think reallocation). So 
libdbus-1 has had for years now this hack that doesn't work that simply makes 
the pointer NULL to indicate that a recursion has happened.

Couple that with threading and you have this issue happening when two separate 
threads try to send a D-Bus message at the same time: when one drops its 
locks, the other one tries to send, and finds the structures set to NULL. That 
second one fails without setting a proper error message, which in libdbus-1 
means "Out of memory".

The fix is to *not* drop the locks and document what the binding may or may not 
do in that callback.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20100527/7d125672/attachment.sig>


More information about the kde-core-devel mailing list