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

List:       kde-commits
Subject:    Re: kdesupport/qt-dbus
From:       Ralf Habacker <ralf.habacker () freenet ! de>
Date:       2006-06-01 22:55:33
Message-ID: 447F7065.4070807 () freenet ! de
[Download RAW message or body]

Thiago Macieira schrieb:
> Ralf Habacker wrote:
>   
>> QWARN  : tst_QDBusConnection::connect() QMutex::lock(): Deadlock
>> detected in thread 2792
>>     
>
> Where is that mutex being locked?
>
>   
The problem i believe is, that QMutex:unlock() is called with a mutex 
already unlocked and that QMutex:unlock() does not detect this case.

I've added some debug printing to QMutex::unlock()

void QMutex::unlock()
{
// debug
        if (d->owner != d->self())
            qDebug("\n QMutex::unlock()  owner: %d self: %d count: %d 
\n",d->owner,d->self(),d->count);

        if (!d->count) {
          qDebug("\nQMutex::unlock() Try to unlock an already unlocked 
mutex.\n");
          //return;  //(1)
      }

// debug
  
       Q_ASSERT_X(d->owner == d->self(), "QMutex::unlock()",
               "A mutex must be unlocked in the same thread that locked 
it.");

    if (!--d->count) {
        d->owner = 0;
        if (!d->lock.testAndSetRelease(1, 0))
            d->wakeUp();
    }
}

If d->count I zero the Mutex is unlocked, which happens some times 
below. If I uncomment the return  (1) no problems more.


----- using qt 4.1.3 release version -----

(gdb) r
Starting program: 
F:\daten\kdesupport\qt-dbus-build-release/bin\tst_qdbusconnection.exe
warning: ********* Start testing of tst_QDBusConnection *********
Config: Using QTest library 4.1.3, Qt 4.1.3

********* Start testing of tst_QDBusConnection *********
Config: Using QTest library 4.1.3, Qt 4.1.3
warning: PASS   : tst_QDBusConnection::initTestCase()

PASS   : tst_QDBusConnection::initTestCase()
warning: QDEBUG : tst_QDBusConnection::addConnection()

 QMutex::unlock()  owner: 0 self: 2536 count: 0


QDEBUG : tst_QDBusConnection::addConnection()
 QMutex::unlock()  owner: 0 self: 2536 count: 0

warning: QDEBUG : tst_QDBusConnection::addConnection()
QMutex::unlock() Try to unlock an already unlocked mutex.


QDEBUG : tst_QDBusConnection::addConnection()
QMutex::unlock() Try to unlock an already unlocked mutex.

warning: QDEBUG : tst_QDBusConnection::addConnection()
QMutex::unlock() Try to unlock an already unlocked mutex.


QDEBUG : tst_QDBusConnection::addConnection()
QMutex::unlock() Try to unlock an already unlocked mutex.

warning: PASS   : tst_QDBusConnection::addConnection()

PASS   : tst_QDBusConnection::addConnection()
warning: QWARN  : tst_QDBusConnection::connect() QMutex::lock(): 
Deadlock detected in thread 2536

QWARN  : tst_QDBusConnection::connect() QMutex::lock(): Deadlock 
detected in thread 2536


----- using qt 4.1.3 debug version -----
 
(gdb) c
Continuing.
warning: ********* Start testing of tst_QDBusConnection *********
Config: Using QTest library 4.1.3, Qt 4.1.3

********* Start testing of tst_QDBusConnection *********
Config: Using QTest library 4.1.3, Qt 4.1.3
warning: PASS   : tst_QDBusConnection::initTestCase()

PASS   : tst_QDBusConnection::initTestCase()
sending message: QDBusMessage(type=MethodCall, 
service="org.freedesktop.DBus", path="/org/freedesktop/DBus", interface=
org.freedesktop.DBus", name="GetNameOwner", signature="", 
contents=(QString("org.freedesktop.DBus") ) )
got message: QDBusMessage(type=MethodReturn, 
service="org.freedesktop.DBus", path="", interface="", name="", signature=
s", contents=(QString("org.freedesktop.DBus") ) )

 QMutex::unlock()  owner: 0 self: 1556 count: 0

Breakpoint 2, QMutex::unlock (this=0x3fb120) at thread/qmutex.cpp:251
251                     qDebug("\nQMutex::unlock() Try to unlock an 
already unlocked mutex.\n");
(gdb) bt
#0  QMutex::unlock (this=0x3fb120) at thread/qmutex.cpp:251
#1  0x0077a3c3 in DBusMutex::mutex_unlock (mutex=0x3fb120)
    at F:/daten/kdesupport/qt-dbus/src/qdbusthread.cpp:54
#2  0x00c37f40 in _dbus_mutex_unlock (mutex=0x3fb120)
    at F:/daten/dbus-win32/dbus/dbus-threads.c:106
#3  0x00c5c09f in _dbus_close (fd=0, error=0x0)
    at F:/daten/dbus-win32/dbus/dbus-sysdeps.c:4395
#4  0x00c3b837 in unix_disconnect (transport=0x3fc3c0)
    at F:/daten/dbus-win32/dbus/dbus-transport-unix.c:890
#5  0x00c392b7 in _dbus_transport_disconnect (transport=0x3fc3c0)
    at F:/daten/dbus-win32/dbus/dbus-transport.c:406
#6  0x00c0ccb1 in dbus_connection_close (connection=0x3fca90)
    at F:/daten/dbus-win32/dbus/dbus-connection.c:1941
#7  0x0072c9b9 in QDBusConnectionPrivate::closeConnection (this=0x3facd8)
    at F:/daten/kdesupport/qt-dbus/src/qdbusintegrator.cpp:749
#8  0x0072c593 in QDBusConnectionPrivate::~QDBusConnectionPrivate (
    this=0x3facd8) at 
F:/daten/kdesupport/qt-dbus/src/qdbusintegrator.cpp:731
#9  0x007238e2 in QDBusConnectionManager::removeConnection (this=0x3fac88,
    name=@0x22f1d0) at 
F:/daten/kdesupport/qt-dbus/src/qdbusconnection.cpp:67
#10 0x00724a44 in QDBusConnection::closeConnection (name=@0x22f1d0)
    at F:/daten/kdesupport/qt-dbus/src/qdbusconnection.cpp:352
#11 0x00403825 in tst_QDBusConnection::addConnection (this=0x22ff40)
    at 
F:/daten/kdesupport/qt-dbus/selftests/qdbusconnection/tst_qdbusconnection---Type 
<return> to continue, or q <ret
rn> to quit---
.cpp:147
#12 0x00406d54 in tst_QDBusConnection::qt_metacall (this=0x22ff40,
    _c=InvokeMetaMethod, _id=0, _a=0x22f340)
    at 
F:/daten/kdesupport/qtdbus-build/selftests/qdbusconnection/tst_qdbusconnection.moc:120
#13 0x005f6657 in 
ZN11QMetaObject12invokeMethodEP7QObjectPKcN2Qt14ConnectionTypeE22QGenericReturnArgument16QGenericArgu
entS7_S7_S7_S7_S7_S7_S7_S7_S7_ ()
   from f:\Qt\4.1.3\bin\QtCore4.dll
#14 0x003d1e3c in ZN5QTest15defaultKeyDelayEv ()
   from f:\Qt\4.1.3\bin\QtTest4.dll
#15 0x003d3a48 in ZN5QTest5qExecEP7QObjectiPPc ()
   from f:\Qt\4.1.3\bin\QtTest4.dll
#16 0x00406b36 in main (argc=1, argv=0x3f4050)
    at 
F:/daten/kdesupport/qt-dbus/selftests/qdbusconnection/tst_qdbusconnection.cpp:255
(gdb)


Regards
 Ralf

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

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