PDA

View Full Version : QTcpSocket exception.



Fastman
28th January 2008, 17:30
I'am have exception in this code:


void CSSocket::incomingData()
{

char szData[4097];

qint16 nRead = this->read(szData, 4096);

if(nRead == 0)
{
this->disconnectFromHost(); // <-------- Exception !
this->close();
return;
}
.....
.....
.....
}

why ???

wysota
28th January 2008, 17:39
What kind of exception? Could you provide more information?

Fastman
28th January 2008, 17:45
What kind of exception? Could you provide more information?


Unhandled exception at 0x64026dfa (QtNetworkd4.dll) in
QMamManager.exe: 0xC0000005:
Access violation writing location 0xfeeefeee.


in -> d:\qt4\src\network\qhostaddress.cpp



void QHostAddressPrivate::clear()
{
a = 0; // <-
protocol = QAbstractSocket::UnknownNetworkLayerProtocol;
isParsed = true;
memset(&a6, 0, sizeof(a6));
}

wysota
28th January 2008, 20:06
Could you provide the back trace (call stack) from the debugger?

Fastman
29th January 2008, 08:14
Could you provide the back trace (call stack) from the debugger?

autos


- this 0xfeeefeee {a=??? a6={...} protocol=??? ...} QHostAddressPrivate * const
a CXX0030: Error: expression cannot be evaluated
+ a6 {c=0xfeeefef2 <Bad Ptr> } QIPv6Address
protocol CXX0030: Error: expression cannot be evaluated
+ ipString {??? size=???} QString
isParsed CXX0030: Error: expression cannot be evaluated
+ scopeId {??? size=???} QString


call stack


> QtNetworkd4.dll!QHostAddressPrivate::clear() Line 242 + 0x3 bytes C++
QtNetworkd4.dll!QHostAddress::clear() Line 437 C++
QtNetworkd4.dll!QAbstractSocket::disconnectFromHos tImplementation() Line 2085 C++
QtNetworkd4.dll!QAbstractSocket::qt_metacall(QMeta Object::Call _c=InvokeMetaMethod, int _id=10, void * * _a=0x00126c64) Line 105 + 0x8 bytes C++
QtNetworkd4.dll!QTcpSocket::qt_metacall(QMetaObjec t::Call _c=InvokeMetaMethod, int _id=17, void * * _a=0x00126c64) Line 56 + 0x14 bytes C++
QMamManager.exe!CSSocket::qt_metacall(QMetaObject: :Call _c=InvokeMetaMethod, int _id=17, void * * _a=0x00126c64) Line 60 + 0x15 bytes C++
QtCored4.dll!QMetaObject::invokeMethod(QObject * obj=0x00a8e220, const char * member=0x64067ce4, Qt::ConnectionType type=DirectConnection, QGenericReturnArgument ret={...}, QGenericArgument val0={...}, QGenericArgument val1={...}, QGenericArgument val2={...}, QGenericArgument val3={...}, QGenericArgument val4={...}, QGenericArgument val5={...}, QGenericArgument val6={...}, QGenericArgument val7={...}, QGenericArgument val8={...}, QGenericArgument val9={...}) Line 973 + 0x1a bytes C++
QtCored4.dll!QMetaObject::invokeMethod(QObject * obj=0x00a8e220, const char * member=0x64067ce4, QGenericArgument val0={...}, QGenericArgument val1={...}, QGenericArgument val2={...}, QGenericArgument val3={...}, QGenericArgument val4={...}, QGenericArgument val5={...}, QGenericArgument val6={...}, QGenericArgument val7={...}, QGenericArgument val8={...}, QGenericArgument val9={...}) Line 363 + 0x72 bytes C++
QtNetworkd4.dll!QAbstractSocket::disconnectFromHos t() Line 2016 + 0xd7 bytes C++
QMamManager.exe!CSSocket::incomingData() Line 74 C++
QMamManager.exe!CSSocket::incomingData() Line 97 C++
QMamManager.exe!CSSocket::qt_metacall(QMetaObject: :Call _c=InvokeMetaMethod, int _id=0, void * * _a=0x00129134) Line 65 + 0x8 bytes C++
QtCored4.dll!QMetaObject::activate(QObject * sender=0x00a8e220, int from_signal_index=4, int to_signal_index=4, void * * argv=0x00000000) Line 3063 + 0x46 bytes C++
QtCored4.dll!QMetaObject::activate(QObject * sender=0x00a8e220, const QMetaObject * m=0x67204804, int local_signal_index=0, void * * argv=0x00000000) Line 3122 + 0x15 bytes C++
QtCored4.dll!QIODevice::readyRead() Line 79 + 0x12 bytes C++
QtNetworkd4.dll!QAbstractSocketPrivate::canReadNot ification() Line 545 C++
QtNetworkd4.dll!QAbstractSocketPrivate::readNotifi cation() Line 55 + 0x12 bytes C++
QtNetworkd4.dll!QAbstractSocketEngine::readNotific ation() Line 119 C++
QtNetworkd4.dll!QReadNotifier::event(QEvent * e=0x001299cc) Line 913 C++
QtGuid4.dll!QApplicationPrivate::notify_helper(QOb ject * receiver=0x00a90828, QEvent * e=0x001299cc) Line 3541 + 0x11 bytes C++
QtGuid4.dll!QApplication::notify(QObject * receiver=0x00a90828, QEvent * e=0x001299cc) Line 3100 + 0x10 bytes C++
QtCored4.dll!QCoreApplication::notifyInternal(QObj ect * receiver=0x00a90828, QEvent * event=0x001299cc) Line 516 C++
QtCored4.dll!QCoreApplication::sendEvent(QObject * receiver=0x00a90828, QEvent * event=0x001299cc) Line 185 + 0x39 bytes C++
QtCored4.dll!qt_internal_proc(HWND__ * hwnd=0x000403ae, unsigned int message=1024, unsigned int wp=5912, long lp=1) Line 241 + 0xf bytes C++
user32.dll!7e368724()
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
user32.dll!7e368806()
user32.dll!7e3689bd()
user32.dll!7e368a00()
QtCored4.dll!QEventDispatcherWin32::processEvents( QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 504 + 0x18 bytes C++
QtGuid4.dll!QGuiEventDispatcherWin32::processEvent s(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 975 + 0x15 bytes C++
QtCored4.dll!QCoreApplication::processEvents(QFlag s<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 666 C++
QMamManager.exe!CProjectManager::WaitRecived() Line 3994 + 0x10 bytes C++
QMamManager.exe!CProjectManager::Autorization() Line 3134 C++
QMamManager.exe!QMamManager::on_pushButton_clicked () Line 22 C++
QMamManager.exe!QMamManager::qt_metacall(QMetaObje ct::Call _c=InvokeMetaMethod, int _id=0, void * * _a=0x0012becc) Line 66 + 0x8 bytes C++
QtCored4.dll!QMetaObject::activate(QObject * sender=0x00a3d950, int from_signal_index=29, int to_signal_index=30, void * * argv=0x0012becc) Line 3063 + 0x46 bytes C++
QtCored4.dll!QMetaObject::activate(QObject * sender=0x00a3d950, const QMetaObject * m=0x6576f0d4, int from_local_signal_index=2, int to_local_signal_index=3, void * * argv=0x0012becc) Line 3142 + 0x15 bytes C++
QtGuid4.dll!QAbstractButton::clicked(bool _t1=false) Line 180 + 0x17 bytes C++
QtGuid4.dll!QAbstractButtonPrivate::emitClicked() Line 517 C++
QtGuid4.dll!QAbstractButtonPrivate::click() Line 509 C++
QtGuid4.dll!QAbstractButton::mouseReleaseEvent(QMo useEvent * e=0x0012c500) Line 1086 C++
QtGuid4.dll!QWidget::event(QEvent * event=0x0012c500) Line 6064 C++
QtGuid4.dll!QAbstractButton::event(QEvent * e=0x0012c500) Line 1048 C++
QtGuid4.dll!QPushButton::event(QEvent * e=0x0012c500) Line 651 C++
QtGuid4.dll!QApplicationPrivate::notify_helper(QOb ject * receiver=0x00a3d950, QEvent * e=0x0012c500) Line 3541 + 0x11 bytes C++
QtGuid4.dll!QApplication::notify(QObject * receiver=0x00a3d950, QEvent * e=0x0012c500) Line 3240 + 0x2f bytes C++
QtCored4.dll!QCoreApplication::notifyInternal(QObj ect * receiver=0x00a3d950, QEvent * event=0x0012c500) Line 516 C++
QtCored4.dll!QCoreApplication::sendSpontaneousEven t(QObject * receiver=0x00a3d950, QEvent * event=0x0012c500) Line 188 + 0x38 bytes C++
QtGuid4.dll!QETWidget::translateMouseEvent(const tagMSG & msg={...}) Line 2757 + 0x14 bytes C++
QtGuid4.dll!QtWndProc(HWND__ * hwnd=0x00040390, unsigned int message=514, unsigned int wParam=0, long lParam=917552) Line 1390 + 0xc bytes C++
user32.dll!7e368724()
user32.dll!7e368806()
user32.dll!7e3689bd()
user32.dll!7e368a00()
QtCored4.dll!QEventDispatcherWin32::processEvents( QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 504 + 0x18 bytes C++
QtGuid4.dll!QGuiEventDispatcherWin32::processEvent s(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 975 + 0x15 bytes C++
QtCored4.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 125 C++
QtCored4.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 170 + 0x2d bytes C++
QtCored4.dll!QCoreApplication::exec() Line 735 + 0x15 bytes C++
QtGuid4.dll!QApplication::exec() Line 3039 C++
QMamManager.exe!main(int argc=1, char * * argv=0x003e7ee0) Line 10 + 0x6 bytes C++
QMamManager.exe!WinMain(HINSTANCE__ * instance=0x00400000, HINSTANCE__ * prevInstance=0x00000000, char * __formal=0x00151f14, int cmdShow=1) Line 103 + 0x12 bytes C++
QMamManager.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
QMamManager.exe!WinMainCRTStartup() Line 403 C
kernel32.dll!7c816ff7()

wysota
29th January 2008, 11:03
Something might be wrong with your stack. 0xfeeefeee seems to be a stack based address. I'd start by recompiling all objects to make sure your application doesn't go into places it shouldn't.

Fastman
29th January 2008, 11:19
hmmm....
If i'am send from server command for disconnect client, i'am get signal disconnected()

connect(this, SIGNAL(disconnected()), this, SLOT(OnCls()));


void CSSocket::OnCls()
{
CProjectManager::GetPrjMng()->Reset();

}

slot work fine... but after quit, i'am get exception in line d->localAddress.clear();


#ifdef QT3_SUPPORT
emit delayedCloseFinished(); // compat signal
#endif
emit disconnected();

d->localPort = 0;
d->peerPort = 0;
d->localAddress.clear(); <----
d->peerAddress.clear();

Fastman
29th January 2008, 12:16
Something might be wrong with your stack. 0xfeeefeee seems to be a stack based address. I'd start by recompiling all objects to make sure your application doesn't go into places it shouldn't.

solved :)
thank you for help ! :)

wysota
29th January 2008, 13:18
What was wrong?

Fastman
29th January 2008, 13:51
What was wrong?

It is my mistake... I tried to cause methods after removal m_pSSocket


void CProjectManager::Reset()
{
CProjectManager::GetPrjMng()->m_pSSocket->disconnectFromHost(); // now ok
CProjectManager::GetPrjMng()->m_pSSocket->close(); // now ok

//delete m_pSSocket; <--
//m_pSSocket = NULL; <--
...
...