-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.6.3, 4.7.4
-
None
-
Qt/Cocoa 4.6.4 (32bit) and Qt/Cocoa 4.7.4 (64bit) under OS X 10.7.2
The following test case runs without problems under OS X 10.6 but often hangs before finishing all iterations under OS X 10.7:
socket.h:
#pragma once
#include <QtCore/QObject>
class SocketTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void start();
};
socket.cpp:
#include "socket.h"
#include <QtCore/QFile>
#include <QtCore/QTimer>
#include <QtNetwork/QLocalServer>
#include <QtGui/QApplication>
#include <QtDebug>
void SocketTest::start()
{
QString socketName = "/tmp/qt-socket-test";
QFile::remove(socketName);
for (int i=0; i < 500; i++)
{
qDebug() << "iteration" << i;
QLocalServer* ls = new QLocalServer;
if (!ls->listen(socketName))
{
qWarning() << "Failed to listen";
}
delete ls;
}
QCoreApplication::quit();
}
int main(int argc, char** argv)
{
QApplication app(argc,argv);
SocketTest* st = new SocketTest;
QTimer::singleShot(50,st,SLOT(start()));
return app.exec();
}
Sample backtrace from gdb:
Thread 1 (process 554): #0 0x0000000102628a69 in spin_lock$VARIANT$mp () #1 0x00007fff93fb9ae2 in __CFSocketCancel () #2 0x00007fff93f9385d in CFRunLoopRemoveSource () #3 0x00007fff93f5e932 in __CFSetApplyFunction_block_invoke_1 () #4 0x00007fff93f5e781 in CFBasicHashApply () #5 0x00007fff93f5e704 in CFSetApplyFunction () #6 0x00007fff93f9373d in CFRunLoopRemoveSource () #7 0x0000000100090b75 in qt_mac_remove_socket_from_runloop (socket=0x102e0ba20, runloop=0x102e12f10) at qeventdispatcher_mac.mm:306 #8 0x0000000100091b0c in QEventDispatcherMac::unregisterSocketNotifier (this=0x1028234f0, notifier=0x102e14910) at qeventdispatcher_mac.mm:437 #9 0x0000000101c7ca09 in QSocketNotifier::setEnabled (this=0x102e14910, enable=false) at qsocketnotifier.cpp:298 #10 0x00000001021c453f in QLocalServerPrivate::closeServer (this=0x102e13220) at qlocalserver_unix.cpp:175 #11 0x00000001021b9ef1 in QLocalServer::close (this=0x102e06410) at qlocalserver.cpp:124 #12 0x00000001021b9fa4 in QLocalServer::~QLocalServer (this=0x102e06410) at qlocalserver.cpp:108 #13 0x00000001000024a6 in SocketTest::start (this=0x106000c60) at socket.cpp:23 Thread 6 (process 554): #0 0x00007fff94da9bf2 in __psynch_mutexwait () #1 0x0000000102577125 in pthread_mutex_lock () #2 0x00007fff93f9fed5 in CFRunLoopWakeUp () #3 0x00007fff93fb9914 in CFSocketInvalidate () #4 0x00007fff93fcdcf3 in __CFSocketManager () #5 0x00000001025794f5 in _pthread_start () #6 0x000000010258077d in thread_start ()
| For Gerrit Dashboard: QTBUG-22789 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 9296,1 | Fix sporadic hang in QLocalServer::close() in OS X 10.7 | master | qt/qtbase | Status: MERGED | +2 | 0 |