Bug 164200

Summary: Crash when call QDBusConnection::disconnectFromBus
Product: [Frameworks and Libraries] kdelibs Reporter: Huang Peng <shawn.p.huang>
Component: qtAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED NOT A BUG    
Severity: crash    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:

Description Huang Peng 2008-06-16 09:48:13 UTC
Version:           4.3.5 (using KDE 4.0.5)
Installed from:    Fedora RPMs
OS:                Linux

Reproduce steps.
1. Call QDBusConnection::connectToBus (address, name)
2. delete the connection
3. Call QDBusConnection::disconnectFromBus
4. crash

Output:
 process 21469: Applications must not close shared connections - see dbus_connection_close() docs. This is a bug in the application.
  D-Bus not built with -rdynamic so unable to print a backtrace
Comment 1 Pino Toscano 2008-06-16 09:53:21 UTC
Did you report the bug to Trolltech? For example, using qt-bugs@trolltech.com
Comment 2 Thiago Macieira 2008-06-16 09:58:20 UTC
#include <QtDBus/QDBusConnection>
#include <QtCore/QCoreApplication>

int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);

    {
        QDBusConnection conn =
            QDBusConnection::connectToBus(QDBusConnection::SessionBus,
                                          "myconnection");
    }

    QDBusConnection::disconnectFromBus("myconnection");
}

No crash. If you have a testcase, please send to trolltech.
Comment 3 Huang Peng 2008-06-16 09:59:02 UTC
No. I will sent a mail to it.
FYI:
QDBusConnection::connectToBus (type, name) uses dbus_bus_get_private to create a private dbus connection (it works fine), but QDBusConnection::connectToBus (address, name) does not use dbus_connection_open_private to create a private connection. So calling disconnectFromBus will cause the crash. I think it's the reason of this bug.
Comment 4 Huang Peng 2008-06-16 10:01:16 UTC
The problem will happens, if connection is created by QDBusConnection::connectToBus (address, name).
Comment 5 Huang Peng 2008-06-16 10:03:21 UTC
Test Case:

QDBusConnection *connection = new QDBusConnection (QDBusConnection::connectToBus (getenv ("DBUS_SESSION_BUS_ADDRESS"), "dbus"));
delete connection;
QDBusConnection::disconnectFromBus ("dbus");
Comment 6 Thiago Macieira 2008-06-16 10:13:13 UTC
Report to trolltech.