[Interest] QNetwork problem in threaded application (repost from development).

Thiago Macieira thiago.macieira at intel.com
Mon Sep 9 17:37:51 CEST 2013


On segunda-feira, 9 de setembro de 2013 15:18:26, Benjamin Zeller wrote:
> sendEvent is used, but the receiver is in another thread, shouldn't it
> use postEvent or better shouldn't the threads eventloop do this stuff?
> As a note: the threads eventloop is not running when the crash occurs,
> maybe thats related to it somehow? Is the QObject only moved competely
> to the thread when its eventloop was started?

sendEvent is supposed to be used there. The object is not supposed to be in 
another thread. All socket notifiers being handled by this thread are in this 
thread.

However, your backtrace shows that the same socket object is being used in the 
two threads:
#2  0x00007f8fe1422e66 in QAbstractSocketPrivate::readNotification 
(this=0xd30ab0) at socket/qabstractsocket_p.h:77
 and
#19 0x00007f8fe141cce7 in QAbstractSocketPrivate::canReadNotification 
(this=0xd30ab0) at socket/qabstractsocket.cpp:701

Note how the "this" pointer is the same in both threads.

I can think of only two problems:

1) there's a bug in your code and you did not move the object as you thought 
you had.

2) there's a lingering bug in the dispatcher that causes it to send events to 
objects that have recently been moved away. For example, it's possible that 
the event dispatcher got woken up by two socket activities. When handling the 
first, you pushed the second socket to another thread. When you resume the 
event loop, the dispatcher still tries to handle the second socket, which has 
now been moved.

PS: please don't send full backtraces, or at least disable printing of 
statics. It's really hard to read it like this.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- 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://lists.qt-project.org/pipermail/interest/attachments/20130909/3ee192cc/attachment.sig>


More information about the Interest mailing list