[Development] QNetwork problem in threaded application.

Benjamin Zeller zeller.benjamin at web.de
Mon Sep 9 11:32:13 CEST 2013


Hello,

i'm currently stress-testing a application at work and came across this
problem.
The application accepts connections and pushes the created sockets
to a worker thread (moveToThread), the worker thread then handles the
rest.
But sometimes when the socket was already closed in the thread i
get a SEGFAULT. It seems something in the mainthread tries to access
the socket engine.

After debugging it i saw that in the backtrace
QCoreApplication::sendEvent is used, instead of postEvent.




Backtrace Mainloop (stops in qabstractsocket.cpp line 741):

     if (readSocketNotifierStateSet && socketEngine &&
 >>        readSocketNotifierState != 
socketEngine->isReadNotificationEnabled()) {
         socketEngine->setReadNotificationEnabled(readSocketNotifierState);
         readSocketNotifierStateSet = false;
     }
     return true;



In the Thread backtrace you can see the thread is closed
------------------------ Backtrace Thread ------------------------------
Thread 17 (Thread 0x7f8fc0df3700 (LWP 5101)):
#0  0x00007f8fe0d397fd in QLocalePrivate::plus (this=0x7f8f9c010260) at 
tools/qlocale_p.h:228
No locals.
#1  0x00007f8fe0d363a0 in QLocalePrivate::unsLongLongToString 
(this=0x7f8f9c010260, l=15, precision=-1, base=10, width=-1, flags=0) at 
tools/qlocale.cpp:3036
No locals.
#2  0x00007f8fe0ddc0af in QTextStreamPrivate::putNumber 
(this=0x7f8f9c0140e0, number=15, negative=false) at io/qtextstream.cpp:2220
         flags = 0
         dd = 0x7f8f9c010260
         result = {static null = {<No data fields>}, d = 0x7f8fe0f5bd60 
<QArrayData::shared_null>}
         numberFlags = {i = 0}
         base = 10
#3  0x00007f8fe0ddc5f0 in QTextStream::operator<< (this=0x7f8f9c012420, 
i=15) at io/qtextstream.cpp:2296
         d = 0x7f8f9c0140e0
         __PRETTY_FUNCTION__ = "QTextStream& QTextStream::operator<<(int)"
#4  0x00007f8fe17463e3 in QDebug::operator<< (this=0x7f8fc0df1cd0, t=15) 
at /opt/Qt/5.1.1/include/QtCore/qdebug.h:107
No locals.
#5  0x00007f8fe17564f3 in Tufao::tDebug () at 
/home/zbenjamin/workspace.work/tufao/src/threadedhttprequestdispatcher.cpp:284
         t = 0xae1440
         __PRETTY_FUNCTION__ = "QDebug Tufao::tDebug()"
#6  0x00007f8fe175c819 in Tufao::WorkerThreadControl::onRequestClosed 
(this=0x7f8fc0df2d50) at 
/home/zbenjamin/workspace.work/tufao/src/priv/workerthreadcontrol.cpp:46
No locals.
#7  0x00007f8fe175c5bd in 
QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, 
void, void (Tufao::WorkerThreadControl::*)()>::call(void 
(Tufao::WorkerThreadControl::*)(), Tufao::WorkerThreadControl*, void**) 
(f=(void (Tufao::WorkerThreadControl::*)(Tufao::WorkerThreadControl * 
const)) 0x7f8fe175c800 <Tufao::WorkerThreadControl::onRequestClosed()>, 
o=0x7f8fc0df2d50, arg=0x7f8fc0df1f30) at 
/opt/Qt/5.1.1/include/QtCore/qobjectdefs_impl.h:508
No locals.
#8  0x00007f8fe175c550 in QtPrivate::FunctionPointer<void 
(Tufao::WorkerThreadControl::*)()>::call<QtPrivate::List<>, void>(void 
(Tufao::WorkerThreadControl::*)(), Tufao::WorkerThreadControl*, void**) 
(f=(void (Tufao::WorkerThreadControl::*)(Tufao::WorkerThreadControl * 
const)) 0x7f8fe175c800 <Tufao::WorkerThreadControl::onRequestClosed()>, 
o=0x7f8fc0df2d50, arg=0x7f8fc0df1f30) at 
/opt/Qt/5.1.1/include/QtCore/qobjectdefs_impl.h:527
No locals.
#9  0x00007f8fe175c4bd in QtPrivate::QSlotObject<void 
(Tufao::WorkerThreadControl::*)(), QtPrivate::List<>, void>::impl(int, 
QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, 
this_=0x7f8f9c0132c0, r=0x7f8fc0df2d50, a=0x7f8fc0df1f30, ret=0x0) at 
/opt/Qt/5.1.1/include/QtCore/qobject_impl.h:147
No locals.
#10 0x00007f8fe0ecc69b in QtPrivate::QSlotObjectBase::call 
(this=0x7f8f9c0132c0, r=0x7f8fc0df2d50, a=0x7f8fc0df1f30) at 
../../include/QtCore/../../src/corelib/kernel/qobject_impl.h:130
No locals.
#11 0x00007f8fe0ec9a02 in QMetaObject::activate (sender=0xc48dd0, 
signalOffset=3, local_signal_index=3, argv=0x0) at kernel/qobject.cpp:3471
         obj = {d = 0x7f8f9c0132c0}
         receiverInSameThread = true
         sw = {receiver = 0x7f8fc0df2d50, previousSender = 0x0, 
currentSender = {sender = 0xc48dd0, signal = 6, ref = 1}, switched = true}
         callFunction = 0x7f8f9c0132c0
         receiver = 0x7f8fc0df2d50
         method_relative = 0
         c = 0x7f8f9c011680
         last = 0x7f8f9c011680
         locker = {val = 140255935355400}
         connectionLists = {connectionLists = 0x1144920}
         list = 0xeeb188
         signal_index = 6
         empty_argv = {0x0}
         currentThreadId = 0x7f8fc0df3700
         __PRETTY_FUNCTION__ = "static void 
QMetaObject::activate(QObject*, int, int, void**)"
#12 0x00007f8fe0ec934c in QMetaObject::activate (sender=0xc48dd0, 
m=0x7f8fe197e4a0 <Tufao::HttpServerRequest::staticMetaObject>, 
local_signal_index=3, argv=0x0) at kernel/qobject.cpp:3354
No locals.
#13 0x00007f8fe175d6c9 in Tufao::HttpServerRequest::close 
(this=0xc48dd0) at 
/home/zbenjamin/workspace.work/tufao-build/src/moc_httpserverrequest.cpp:193
No locals.
#14 0x00007f8fe175d39c in Tufao::HttpServerRequest::qt_static_metacall 
(_o=0xc48dd0, _c=QMetaObject::InvokeMetaMethod, _id=3, 
_a=0x7f8fc0df2120) at 
/home/zbenjamin/workspace.work/tufao-build/src/moc_httpserverrequest.cpp:93
         _t = 0xc48dd0
#15 0x00007f8fe0ec9afb in QMetaObject::activate (sender=0x11010b0, 
signalOffset=7, local_signal_index=2, argv=0x0) at kernel/qobject.cpp:3479
         receiverInSameThread = true
         sw = {receiver = 0xc48dd0, previousSender = 0x0, currentSender 
= {sender = 0x11010b0, signal = 9, ref = 1}, switched = true}
         callFunction = 0x7f8fe175d310 
<Tufao::HttpServerRequest::qt_static_metacall(QObject*, 
QMetaObject::Call, int, void**)>
         receiver = 0xc48dd0
         method_relative = 3
         c = 0xdefea0
         last = 0xe338e0
         locker = {val = 140255935355448}
         connectionLists = {connectionLists = 0x113e4e0}
         list = 0xbf3858
         signal_index = 9
         empty_argv = {0x0}
         currentThreadId = 0x7f8fc0df3700
         __PRETTY_FUNCTION__ = "static void 
QMetaObject::activate(QObject*, int, int, void**)"
#16 0x00007f8fe0ec934c in QMetaObject::activate (sender=0x11010b0, 
m=0x7f8fe16cd1e0 <QAbstractSocket::staticMetaObject>, 
local_signal_index=2, argv=0x0) at kernel/qobject.cpp:3354
No locals.
#17 0x00007f8fe142276d in QAbstractSocket::disconnected (this=0x11010b0) 
at .moc/debug-shared/moc_qabstractsocket.cpp:366
No locals.
#18 0x00007f8fe1421c42 in QAbstractSocket::disconnectFromHost 
(this=0x11010b0) at socket/qabstractsocket.cpp:2700
         d = 0xd30ab0
         previousState = QAbstractSocket::ClosingState
#19 0x00007f8fe141cce7 in QAbstractSocketPrivate::canReadNotification 
(this=0xd30ab0) at socket/qabstractsocket.cpp:701
         q = 0x11010b0
         rsncrollback = {varRef = @0xd30b88, oldValue = true}
         newBytes = 0
         hasData = false
#20 0x00007f8fe1420b8a in QAbstractSocket::waitForBytesWritten 
(this=0x11010b0, msecs=30000) at socket/qabstractsocket.cpp:2181
         readyToRead = true
         readyToWrite = true
         d = 0xd30ab0
         __PRETTY_FUNCTION__ = "virtual bool 
QAbstractSocket::waitForBytesWritten(int)"
         stopWatch = {t1 = 10161, t2 = 636117446}
#21 0x00007f8fe173b359 in Tufao::HttpFileServer::serveFile 
(fileName=..., request=..., response=...) at 
/home/zbenjamin/workspace.work/tufao/src/httpfileserver.cpp:243
         fileInfo = {d_ptr = {d = 0x7f8f9c012920}}
         file = {<QFileDevice> = {<QIODevice> = {<QObject> = 
{_vptr.QObject = 0x7f8fe133fc50 <vtable for QFile+16>, static 
staticMetaObject = {d = {superdata = 0x0, stringdata = 0x7f8fe1001520 
<qt_meta_stringdata_QObject>, data = 0x7f8fe1001640 
<qt_meta_data_QObject>, static_metacall = 0x7f8fe0ecbff4 
<QObject::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, 
relatedMetaObjects = 0x0, extradata = 0x0}}, d_ptr = {d = 
0x7f8f9c010cb0}, static staticQtMetaObject = {d = {superdata = 0x0, 
stringdata = 0x7f8fe104e220 <qt_meta_stringdata_Qt>, data = 
0x7f8fe1057c00 <qt_meta_data_Qt>, static_metacall = 0x0, 
relatedMetaObjects = 0x0, extradata = 0x0}}}, static staticMetaObject = 
{d = {superdata = 0x7f8fe133df20 <QObject::staticMetaObject>, stringdata 
= 0x7f8fe1061e40 <qt_meta_stringdata_QIODevice>, data = 0x7f8fe1061f40 
<qt_meta_data_QIODevice>, static_metacall = 0x7f8fe0f4f7a0 
<QIODevice::qt_static_metacall(QObject*, QMetaObject::Call, int, 
void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}}, static 
staticMetaObject = {d = {superdata = 0x7f8fe133ff00 
<QIODevice::staticMetaObject>, stringdata = 0x7f8fe1061d40 
<qt_meta_stringdata_QFileDevice>, data = 0x7f8fe1061d80 
<qt_meta_data_QFileDevice>, static_metacall = 0x7f8fe0f4f6b4 
<QFileDevice::qt_static_metacall(QObject*, QMetaObject::Call, int, 
void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}}, static 
staticMetaObject = {d = {superdata = 0x7f8fe133fd80 
<QFileDevice::staticMetaObject>, stringdata = 0x7f8fe1061c60 
<qt_meta_stringdata_QFile>, data = 0x7f8fe1061c80 <qt_meta_data_QFile>, 
static_metacall = 0x7f8fe0f4f5c8 <QFile::qt_static_metacall(QObject*, 
QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 
0x0}}}
         ranges = {{p = {static shared_null = {ref = {atomic = {_q_value 
= -1}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, d = 
0x7f8fe0f5e950 <QListData::shared_null>}, d = 0x7f8fe0f5e950 
<QListData::shared_null>}}
         __PRETTY_FUNCTION__ = "static void 
Tufao::HttpFileServer::serveFile(const QString&, 
Tufao::HttpServerRequest&, Tufao::HttpServerResponse&)"
#22 0x00007f8fe173d445 in Tufao::HttpFileServer::handleRequest 
(request=..., response=..., rootDir=...) at 
/home/zbenjamin/workspace.work/tufao/src/httpfileserver.cpp:373
         fileName = {static null = {<No data fields>}, d = 0x7f8f9c00fbf0}
#23 0x00007f8fe173c7b3 in Tufao::HttpFileServer::__lambda1::operator() 
(__closure=0x7f8f9c003530, request=..., response=...) at 
/home/zbenjamin/workspace.work/tufao/src/httpfileserver.cpp:347
         dir = {static null = {<No data fields>}, d = 0xae18a0}
#24 0x00007f8fe173ca0d in 
std::_Function_handler<bool(Tufao::HttpServerRequest&, 
Tufao::HttpServerResponse&), Tufao::HttpFileServer::handler(const 
QString&)::__lambda1>::_M_invoke(const std::_Any_data &, 
Tufao::HttpServerRequest &, Tufao::HttpServerResponse &) (__functor=..., 
__args#0=..., __args#1=...) at /usr/include/c++/4.8.1/functional:2057
No locals.
#25 0x00007f8fe173f64f in std::function<bool (Tufao::HttpServerRequest&, 
Tufao::HttpServerResponse&)>::operator()(Tufao::HttpServerRequest&, 
Tufao::HttpServerResponse&) const (this=0x7f8f9c0034a8, __args#0=..., 
__args#1=...) at /usr/include/c++/4.8.1/functional:2468
No locals.
#26 0x00007f8fe173e6e4 in Tufao::HttpServerRequestRouter::handleRequest 
(this=0x7f8f9c0013b0, request=..., response=...) at 
/home/zbenjamin/workspace.work/tufao/src/httpserverrequestrouter.cpp:96
         args = {<QList<QString>> = {{p = {static shared_null = {ref = 
{atomic = {_q_value = -1}}, alloc = 0, begin = 0, end = 0, array = 
{0x0}}, d = 0x7f8fe0f5e950 <QListData::shared_null>}, d = 0x7f8fe0f5e950 
<QListData::shared_null>}}, <No data fields>}
         backup = {d = {data = {c = 0 '\000', uc = 0 '\000', s = 0, sc = 
0 '\000', us = 0, i = 0, u = 0, l = 0, ul = 0, b = false, d = 0, f = 0, 
real = 0, ll = 0, ull = 0, o = 0x0, ptr = 0x0, shared = 0x0}, type = 0, 
is_shared = 0, is_null = 1}}
         match = {d = {d = 0x7f8f9c015860}}
         mapping = @0x7f8f9c003498: {path = {d = {d = 0x7f8f9c003240}}, 
method = {d = 0x7f8fe0f5bd60 <QArrayData::shared_null>}, handler = 
{<std::_Maybe_unary_or_binary_function<bool, Tufao::HttpServerRequest&, 
Tufao::HttpServerResponse&>> = 
{<std::binary_function<Tufao::HttpServerRequest&, 
Tufao::HttpServerResponse&, bool>> = {<No data fields>}, <No data 
fields>}, <std::_Function_base> = {static _M_max_size = 16, static 
_M_max_align = 8, _M_functor = {_M_unused = {_M_object = 0x7f8f9c003530, 
_M_const_object = 0x7f8f9c003530, _M_function_pointer = 0x7f8f9c003530, 
_M_member_pointer = (void 
(std::_Undefined_class::*)(std::_Undefined_class * const)) 
0x7f8f9c003530}, _M_pod_data = 
"05\000\234\217\177\000\000\000\000\000\000\000\000\000"}, _M_manager = 
0x7f8fe173ca16 
<std::_Function_base::_Base_manager<Tufao::HttpFileServer::handler(const 
QString&)::__lambda1>::_M_manager(std::_Any_data &, const std::_Any_data 
&, std::_Manager_operation)>}, _M_invoker = 0x7f8fe173c9be 
<std::_Function_handler<bool(Tufao::HttpServerRequest&, 
Tufao::HttpServerResponse&), Tufao::HttpFileServer::handler(const 
QString&)::__lambda1>::_M_invoke(const std::_Any_data &, 
Tufao::HttpServerRequest &, Tufao::HttpServerResponse &)>}}
         __for_range = @0x7f8f9c0013e0: {d = 0x7f8f9c003450}
         __for_begin = 0x7f8f9c003498
         __for_end = 0x7f8f9c0034f8
         path = {static null = {<No data fields>}, d = 0xde41c0}
#27 0x00007f8fe175bb87 in Tufao::WorkerThread::run (this=0xae1440) at 
/home/zbenjamin/workspace.work/tufao/src/priv/workerthread.cpp:117
         request = {wp = {d = 0x1151eb0, value = 0xc48dd0}}
         response = {wp = {d = 0x1064240, value = 0xe9e8a0}}
         handled = true
         customData = 0x7f8f9c0029a0
         handler = 0x7f8f9c0013c0
         controller = {<QObject> = {_vptr.QObject = 0x7f8fe197ec90 
<vtable for Tufao::WorkerThreadControl+16>, static staticMetaObject = {d 
= {superdata = 0x0, stringdata = 0x7f8fe1001520 
<qt_meta_stringdata_QObject>, data = 0x7f8fe1001640 
<qt_meta_data_QObject>, static_metacall = 0x7f8fe0ecbff4 
<QObject::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, 
relatedMetaObjects = 0x0, extradata = 0x0}}, d_ptr = {d = 
0x7f8f9c0033d0}, static staticQtMetaObject = {d = {superdata = 0x0, 
stringdata = 0x7f8fe104e220 <qt_meta_stringdata_Qt>, data = 
0x7f8fe1057c00 <qt_meta_data_Qt>, static_metacall = 0x0, 
relatedMetaObjects = 0x0, extradata = 0x0}}}, static staticMetaObject = 
{d = {superdata = 0x7f8fe133df20 <QObject::staticMetaObject>, stringdata 
= 0x7f8fe1765be0 <qt_meta_stringdata_Tufao__WorkerThreadControl>, data = 
0x7f8fe1765cc0 <qt_meta_data_Tufao__WorkerThreadControl>, 
static_metacall = 0x7f8fe175e550 
<Tufao::WorkerThreadControl::qt_static_metacall(QObject*, 
QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 
0x0}}}
         __PRETTY_FUNCTION__ = "virtual void Tufao::WorkerThread::run()"
#28 0x00007f8fe0c99cec in QThreadPrivate::start (arg=0xae1440) at 
thread/qthread_unix.cpp:345
         __clframe = {__cancel_routine = 0x7f8fe0c99d80 
<QThreadPrivate::finish(void*)>, __cancel_arg = 0xae1440, __do_it = 1, 
__cancel_type = 0}
         thr = 0xae1440
         data = 0xae1600
         objectName = {static null = {<No data fields>}, d = 
0x7f8fe0f5bd60 <QArrayData::shared_null>}
#29 0x00007f8fe09e20a2 in start_thread () from /usr/lib/libpthread.so.0
No symbol table info available.
#30 0x00007f8fdfef7a2d in clone () from /usr/lib/libc.so.6
No symbol table info available.



In the main backtrace the receiver is accessed, but it belongs to 
another thread:

------------------------------------ Backtrace MAIN -------------------

Thread 1 (Thread 0x7f8fe1b5c740 (LWP 5077)):
#0  0x00007f8fe1002050 in typeinfo name for QObjectPrivate () from 
/opt/Qt/5.1.1/lib/libQt5Core.so.5
No symbol table info available.
#1  0x00007f8fe141cf33 in QAbstractSocketPrivate::canReadNotification 
(this=0xd30ab0) at socket/qabstractsocket.cpp:741
         q = 0x11010b0
         rsncrollback = {varRef = @0xd30b88, oldValue = false}
         newBytes = 76
         hasData = true
#2  0x00007f8fe1422e66 in QAbstractSocketPrivate::readNotification 
(this=0xd30ab0) at socket/qabstractsocket_p.h:77
No locals.
#3  0x00007f8fe140ece5 in QAbstractSocketEngine::readNotification 
(this=0x15a25d0) at socket/qabstractsocketengine.cpp:156
         receiver = 0xd30b80
#4  0x00007f8fe142b294 in QReadNotifier::event (this=0x15a25f0, 
e=0x7fff2d1ecce0) at socket/qnativesocketengine.cpp:1147
No locals.
#5  0x00007f8fe0e8a18c in QCoreApplicationPrivate::notify_helper 
(this=0xad7ae0, receiver=0x15a25f0, event=0x7fff2d1ecce0) at 
kernel/qcoreapplication.cpp:984
No locals.
#6  0x00007f8fe0e89e4e in QCoreApplication::notify (this=0x7fff2d1ed070, 
receiver=0x15a25f0, event=0x7fff2d1ecce0) at kernel/qcoreapplication.cpp:929
         d = 0xad7ae0
         __PRETTY_FUNCTION__ = "virtual bool 
QCoreApplication::notify(QObject*, QEvent*)"
#7  0x00007f8fe0e89d56 in QCoreApplication::notifyInternal 
(this=0x7fff2d1ed070, receiver=0x15a25f0, event=0x7fff2d1ecce0) at 
kernel/qcoreapplication.cpp:867
         threadData = 0xad7ba0
         loopLevelCounter = {threadData = 0xad7ba0}
         result = false
         cbdata = {0x15a25f0, 0x7fff2d1ecce0, 0x7fff2d1ecc6f}
         d = 0xf67e80
#8  0x00007f8fe0e8d8bb in QCoreApplication::sendEvent 
(receiver=0x15a25f0, event=0x7fff2d1ecce0) at 
../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:232
No locals.
#9  0x00007f8fe0ef94b0 in socketNotifierSourceDispatch (source=0xada340) 
at kernel/qeventdispatcher_glib.cpp:109
         p = 0x15a24e0
         i = 54
         event = {_vptr.QEvent = 0x7f8fe133ddf0 <vtable for QEvent+16>, 
static staticMetaObject = {d = {superdata = 0x0, stringdata = 
0x7f8fe10649a0 <qt_meta_stringdata_QEvent>, data = 0x7f8fe1066320 
<qt_meta_data_QEvent>, static_metacall = 0x0, relatedMetaObjects = 0x0, 
extradata = 0x0}}, d = 0x0, t = 50, posted = 0, spont = 0, m_accept = 1, 
reserved = 33}
         src = 0xada340
#10 0x00007f8fdeb6cd96 in g_main_context_dispatch () from 
/usr/lib/libglib-2.0.so.0
No symbol table info available.
#11 0x00007f8fdeb6d0e8 in ?? () from /usr/lib/libglib-2.0.so.0
No symbol table info available.
#12 0x00007f8fdeb6d18c in g_main_context_iteration () from 
/usr/lib/libglib-2.0.so.0
No symbol table info available.
#13 0x00007f8fe0efa163 in QEventDispatcherGlib::processEvents 
(this=0xad8df0, flags=...) at kernel/qeventdispatcher_glib.cpp:426
         d = 0xad8e10
         canWait = true
         savedFlags = {i = 0}
         result = false
#14 0x00007f8fe0e86ab6 in QEventLoop::processEvents 
(this=0x7fff2d1ecf80, flags=...) at kernel/qeventloop.cpp:136
         d = 0xb081b0
#15 0x00007f8fe0e86d99 in QEventLoop::exec (this=0x7fff2d1ecf80, 
flags=...) at kernel/qeventloop.cpp:212
         locker = {val = 11369632}
         __PRETTY_FUNCTION__ = "int 
QEventLoop::exec(QEventLoop::ProcessEventsFlags)"
         ref = {d = 0xb081b0, locker = @0x7fff2d1ecf00, exceptionCaught 
= true}
         app = 0x7fff2d1ed070
         d = 0xb081b0
#16 0x00007f8fe0e8a432 in QCoreApplication::exec () at 
kernel/qcoreapplication.cpp:1120
         threadData = 0xad7ba0
         __PRETTY_FUNCTION__ = "static int QCoreApplication::exec()"
         eventLoop = {<QObject> = {_vptr.QObject = 0x7f8fe1341670 
<vtable for QEventLoop+16>, static staticMetaObject = {d = {superdata = 
0x0, stringdata = 0x7f8fe1001520 <qt_meta_stringdata_QObject>, data = 
0x7f8fe1001640 <qt_meta_data_QObject>, static_metacall = 0x7f8fe0ecbff4 
<QObject::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, 
relatedMetaObjects = 0x0, extradata = 0x0}}, d_ptr = {d = 0xb081b0}, 
static staticQtMetaObject = {d = {superdata = 0x0, stringdata = 
0x7f8fe104e220 <qt_meta_stringdata_Qt>, data = 0x7f8fe1057c00 
<qt_meta_data_Qt>, static_metacall = 0x0, relatedMetaObjects = 0x0, 
extradata = 0x0}}}, static staticMetaObject = {d = {superdata = 
0x7f8fe133df20 <QObject::staticMetaObject>, stringdata = 0x7f8fe10644a0 
<qt_meta_stringdata_QEventLoop>, data = 0x7f8fe1064500 
<qt_meta_data_QEventLoop>, static_metacall = 0x7f8fe0f52aa0 
<QEventLoop::qt_static_metacall(QObject*, QMetaObject::Call, int, 
void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}}
         returnCode = 32655
#17 0x00000000004036a4 in main (argc=1, argv=0x7fff2d1ed1e8) at 
../../../src/server/main.cpp:85
         a = {<QObject> = {_vptr.QObject = 0x7f8fe1341750 <vtable for 
QCoreApplication+16>, static staticMetaObject = {d = {superdata = 0x0, 
stringdata = 0x7f8fe1001520 <qt_meta_stringdata_QObject>, data = 
0x7f8fe1001640 <qt_meta_data_QObject>, static_metacall = 0x7f8fe0ecbff4 
<QObject::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, 
relatedMetaObjects = 0x0, extradata = 0x0}}, d_ptr = {d = 0xad7ae0}, 
static staticQtMetaObject = {d = {superdata = 0x0, stringdata = 
0x7f8fe104e220 <qt_meta_stringdata_Qt>, data = 0x7f8fe1057c00 
<qt_meta_data_Qt>, static_metacall = 0x0, relatedMetaObjects = 0x0, 
extradata = 0x0}}}, static staticMetaObject = {d = {superdata = 
0x7f8fe133df20 <QObject::staticMetaObject>, stringdata = 0x7f8fe1064620 
<qt_meta_stringdata_QCoreApplication>, data = 0x7f8fe1064840 
<qt_meta_data_QCoreApplication>, static_metacall = 0x7f8fe0f52bf8 
<QCoreApplication::qt_static_metacall(QObject*, QMetaObject::Call, int, 
void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}, static self = 
0x7fff2d1ed070}
         server = {<QObject> = {_vptr.QObject = 0x7f8fe197f190 <vtable 
for Tufao::HttpServer+16>, static staticMetaObject = {d = {superdata = 
0x0, stringdata = 0x7f8fe1001520 <qt_meta_stringdata_QObject>, data = 
0x7f8fe1001640 <qt_meta_data_QObject>, static_metacall = 0x7f8fe0ecbff4 
<QObject::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, 
relatedMetaObjects = 0x0, extradata = 0x0}}, d_ptr = {d = 0xadb6e0}, 
static staticQtMetaObject = {d = {superdata = 0x0, stringdata = 
0x7f8fe104e220 <qt_meta_stringdata_Qt>, data = 0x7f8fe1057c00 
<qt_meta_data_Qt>, static_metacall = 0x0, relatedMetaObjects = 0x0, 
extradata = 0x0}}}, static staticMetaObject = {d = {superdata = 
0x7f8fe133df20 <QObject::staticMetaObject>, stringdata = 0x7f8fe1764b80 
<qt_meta_stringdata_Tufao__HttpServer>, data = 0x7f8fe1764d80 
<qt_meta_data_Tufao__HttpServer>, static_metacall = 0x7f8fe175d06e 
<Tufao::HttpServer::qt_static_metacall(QObject*, QMetaObject::Call, int, 
void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}, priv = 0xadb760}
         pServer = {<Tufao::ThreadedHttpRequestDispatcher> = {<QObject> 
= {_vptr.QObject = 0x7f8fe197ea50 <vtable for 
Tufao::ThreadedHttpPluginServer+16>, static staticMetaObject = {d = 
{superdata = 0x0, stringdata = 0x7f8fe1001520 
<qt_meta_stringdata_QObject>, data = 0x7f8fe1001640 
<qt_meta_data_QObject>, static_metacall = 0x7f8fe0ecbff4 
<QObject::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, 
relatedMetaObjects = 0x0, extradata = 0x0}}, d_ptr = {d = 0xadc1f0}, 
static staticQtMetaObject = {d = {superdata = 0x0, stringdata = 
0x7f8fe104e220 <qt_meta_stringdata_Qt>, data = 0x7f8fe1057c00 
<qt_meta_data_Qt>, static_metacall = 0x0, relatedMetaObjects = 0x0, 
extradata = 0x0}}}, <Tufao::AbstractHttpServerRequestHandler> = 
{_vptr.AbstractHttpServerRequestHandler = 0x7f8fe197ead0 <vtable for 
Tufao::ThreadedHttpPluginServer+144>}, static staticMetaObject = {d = 
{superdata = 0x7f8fe133df20 <QObject::staticMetaObject>, stringdata = 
0x7f8fe1765fa0 
<qt_meta_stringdata_Tufao__ThreadedHttpRequestDispatcher>, data = 
0x7f8fe1766100 <qt_meta_data_Tufao__ThreadedHttpRequestDispatcher>, 
static_metacall = 0x7f8fe175ea76 
<Tufao::ThreadedHttpRequestDispatcher::qt_static_metacall(QObject*, 
QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 
0x0}}, priv = 0xadbaa0}, static staticMetaObject = {d = {superdata = 
0x7f8fe197e7a0 <Tufao::ThreadedHttpRequestDispatcher::staticMetaObject>, 
stringdata = 0x7f8fe1765ec0 
<qt_meta_stringdata_Tufao__ThreadedHttpPluginServer>, data = 
0x7f8fe1765f40 <qt_meta_data_Tufao__ThreadedHttpPluginServer>, 
static_metacall = 0x7f8fe175e912 
<Tufao::ThreadedHttpPluginServer::qt_static_metacall(QObject*, 
QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 
0x0}}}


------------------------------------------------------------------------------

Thats where the problem might be:


static gboolean socketNotifierSourceDispatch(GSource *source, 
GSourceFunc, gpointer)
{
     QEvent event(QEvent::SockAct);

     GSocketNotifierSource *src = reinterpret_cast<GSocketNotifierSource 
*>(source);
     for (int i = 0; i < src->pollfds.count(); ++i) {
         GPollFDWithQSocketNotifier *p = src->pollfds.at(i);

         if ((p->pollfd.revents & p->pollfd.events) != 0)
             QCoreApplication::sendEvent(p->socketNotifier, &event);
     }

     return true; // ??? don't remove, right?
}

sendEvent is used, but the receiver is in another thread, shouldn't it
use postEvent?

I'm on Linux, Qt 5.1.1 gcc




More information about the Development mailing list