PDA

View Full Version : QNetworkInterface::allAddresses() crash



^NyAw^
20th November 2007, 15:15
Hi,
I'm trying this code



QList<QNetworkInterface> qLlistaInterfaces = QNetworkInterface::allInterfaces();
qLlistaInterfaces.clear();


When I call "clear" the program crash. I call "clear" because my program crashes when exitting the function that is calling "allInterfaces" and I found that the problem is in clearing the list.

I'm doing something wrong?

Thanks,

^NyAw^
20th November 2007, 17:50
Hi,

Anyone can test if clearing the list, the program crash?

Thanks,

DeepDiver
20th November 2007, 18:04
no problem on debian linux qt 4.3.2.
Did you build qt yourself?
Platform?
Compiler?
...

^NyAw^
20th November 2007, 18:15
Hi,

Qt 4.3.0 Commercial on Windows XP

Compiler: Visual Studio 2003 .NET

Thanks,

^NyAw^
20th November 2007, 22:15
Hi,

Anyone can try this piece of code?

I have two ethernet interfaces. Could this be the problem?

Thanks,

jpn
21st November 2007, 09:59
I have tested the above snippet with Qt 4.3.2 and MSVC 2005 SP1. It works without any problems for me. I seem to have 4 interfaces.

Edit: Could you paste callstack from a crash?

^NyAw^
21st November 2007, 12:19
Hi,

The call Stack:



ntdll.dll!7c911230()
ntdll.dll!7c97c943()
ntdll.dll!7c97cd80()
ntdll.dll!7c970af8()
kernel32.dll!7c85e7af()
> msvcr71d.dll!_CrtIsValidHeapPointer(const void * pUserData=0x01d96a88) LÃ*nea 1818 C
msvcr71d.dll!_free_dbg_lk(void * pUserData=0x01d96a88, int nBlockUse=1) LÃ*nea 1143 + 0x9 C
msvcr71d.dll!_free_dbg(void * pUserData=0x01d96a88, int nBlockUse=1) LÃ*nea 1081 + 0xd C
msvcr71d.dll!operator delete(void * pUserData=0x01d96a88) LÃ*nea 54 + 0x10 C++
MagicVision.exe!QNetworkInterface::`scalar deleting destructor'() + 0x21 C++
MagicVision.exe!QList<QNetworkInterface>::node_destruct(QList<QNetworkInterface>::Node * from=0x02219034, QList<QNetworkInterface>::Node * to=0x0221903c) LÃ*nea 340 + 0x2f C++
MagicVision.exe!QList<QNetworkInterface>::free(QListData::Data * data=0x02219020) LÃ*nea 539 C++
MagicVision.exe!QList<QNetworkInterface>::operator=(const QList<QNetworkInterface> & l={...}) LÃ*nea 354 C++
MagicVision.exe!QList<QNetworkInterface>::clear() LÃ*nea 547 + 0x24 C++
MagicVision.exe!ConfiguracioIODialog::setupProject e(CLlistaProgrames * pCProjecte=0x01c283d0) LÃ*nea 98 C++
MagicVision.exe!CVistaProjecte::ConfigurarES() LÃ*nea 1105 C++
MagicVision.exe!CVistaProjecte::qt_metacall(QMetaO bject::Call _c=InvokeMetaMethod, int _id=20, void * * _a=0x0012bdb4) LÃ*nea 119 C++
QtCored4.dll!QMetaObject::activate(QObject * sender=0x01c28860, int from_signal_index=29, int to_signal_index=30, void * * argv=0x0012bdb4) LÃ*nea 3064 + 0x46 C++
QtCored4.dll!QMetaObject::activate(QObject * sender=0x01c28860, const QMetaObject * m=0x65795e74, int from_local_signal_index=2, int to_local_signal_index=3, void * * argv=0x0012bdb4) LÃ*nea 3143 + 0x15 C++
QtGuid4.dll!QAbstractButton::clicked(bool _t1=false) LÃ*nea 180 + 0x17 C++
QtGuid4.dll!QAbstractButtonPrivate::emitClicked() LÃ*nea 517 C++
QtGuid4.dll!QAbstractButtonPrivate::click() LÃ*nea 509 C++
QtGuid4.dll!QAbstractButton::mouseReleaseEvent(QMo useEvent * e=0x0012c3e8) LÃ*nea 1086 C++
QtGuid4.dll!QWidget::event(QEvent * event=0x0012c3e8) LÃ*nea 6030 C++
QtGuid4.dll!QAbstractButton::event(QEvent * e=0x0012c3e8) LÃ*nea 1048 C++
QtGuid4.dll!QPushButton::event(QEvent * e=0x0012c3e8) LÃ*nea 651 C++
QtGuid4.dll!QApplicationPrivate::notify_helper(QOb ject * receiver=0x01c28860, QEvent * e=0x0012c3e8) LÃ*nea 3536 + 0x11 C++
QtGuid4.dll!QApplication::notify(QObject * receiver=0x01c28860, QEvent * e=0x0012c3e8) LÃ*nea 3235 + 0x2f C++
QtCored4.dll!QCoreApplication::notifyInternal(QObj ect * receiver=0x01c28860, QEvent * event=0x0012c3e8) LÃ*nea 508 C++
QtCored4.dll!QCoreApplication::sendSpontaneousEven t(QObject * receiver=0x01c28860, QEvent * event=0x0012c3e8) LÃ*nea 187 + 0x38 C++
QtGuid4.dll!QETWidget::translateMouseEvent(const tagMSG & msg={...}) LÃ*nea 2744 + 0x14 C++
QtGuid4.dll!QtWndProc(HWND__ * hwnd=0x00021032, unsigned int message=514, unsigned int wParam=0, long lParam=589835) LÃ*nea 1376 + 0xc C++
user32.dll!77d18709()
user32.dll!77d187eb()
user32.dll!77d40494()
user32.dll!77d189a5()
user32.dll!77d40494()
user32.dll!77d189e8()
QtCored4.dll!QEventDispatcherWin32::processEvents( QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) LÃ*nea 519 + 0x18 C++
QtGuid4.dll!QGuiEventDispatcherWin32::processEvent s(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) LÃ*nea 963 + 0x15 C++
QtCored4.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) LÃ*nea 125 C++
QtCored4.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) LÃ*nea 170 + 0x2d C++
QtCored4.dll!QCoreApplication::exec() LÃ*nea 727 + 0x15 C++
QtGuid4.dll!QApplication::exec() LÃ*nea 3034 C++
MagicVision.exe!main(int argc=1, char * * argv=0x01a18468) LÃ*nea 57 + 0x6 C++
MagicVision.exe!WinMain(HINSTANCE__ * instance=0x00400000, HINSTANCE__ * prevInstance=0x00000000, char * __formal=0x00151f17, int cmdShow=1) LÃ*nea 103 + 0x12 C++
MagicVision.exe!WinMainCRTStartup() LÃ*nea 390 + 0x39 C
kernel32.dll!7c816d4f()
kernel32.dll!7c8399f3()
QtXmld4.dll!QXmlNamespaceSupport::prefix(const QString & uri=) LÃ*nea 728 + 0x17 C++



Thanks,

jpn
21st November 2007, 13:28
Just to make sure it's not accidentally caused by your application, could you test:


// main.cpp
#include <QCoreApplication>
#include <QNetworkInterface>
#include <QtDebug>

int main(int argc, char* argv[])
{
QCoreApplication app(argc, argv);
QList<QNetworkInterface> list = QNetworkInterface::allInterfaces();
qDebug() << list;
list.clear();
return 0;
}


PS. And what if you try to update to Qt 4.3.2? I couldn't see anything relevant in task-tracker or lists of changes but it works for me.. :)

http://trolltech.com/developer/task-tracker
http://trolltech.com/developer/notes/changes/changes-4.3.1
http://trolltech.com/developer/notes/changes/changes-4.3.2

^NyAw^
21st November 2007, 14:34
Hi,

I attached an image that swhows that it crash.

Will try to update to Qt 4.3.2

Thanks,

dpatel
21st January 2011, 13:30
I am facing exactly same issue. My configuration is Qt 4.6.2 using with MSVC 2005 on Win XP.
Its crashing at the same location for me as well i.e during destruction of QNetworkInterface.

I have tried few things as below.

1) I get similar crash when I use


QList<QNetworkInterface> list= QNetworkInterface::allInterfaces();



This time which destroying QNetworkInterface object.

2) More interestingly I only get this issue in GUI based project created with VS2005. I create Qt GUI project using QtCreator 2.0.1 which has the same code and it works fine. If I create console application using VS 2005 having same code, it works fine.

My code is very simple


QList<QHostAddress> list=net.allAddresses();


And I get crash when 'list' goes out of scope.

For sake of completeness here is backtrace



> msvcr80d.dll!_CrtIsValidHeapPointer(const void * pUserData=0x00cc4ea8) Line 2072 C++
msvcr80d.dll!_free_dbg_nolock(void * pUserData=0x00cc4ea8, int nBlockUse=1) Line 1279 + 0x9 bytes C++
msvcr80d.dll!_free_dbg(void * pUserData=0x00cc4ea8, int nBlockUse=1) Line 1220 + 0xd bytes C++
msvcr80d.dll!operator delete(void * pUserData=0x00cc4ea8) Line 54 + 0x10 bytes C++
GUI.exe!QHostAddress::`scalar deleting destructor'() + 0x21 bytes C++
GUI.exe!QList<QHostAddress>::node_destruct(QList<QHostAddress>::Node * from=0x00cc9604, QList<QHostAddress>::Node * to=0x00cc9628) Line 402 + 0x2f bytes C++
GUI.exe!QList<QHostAddress>::free(QListData::Data * data=0x00cc95f0) Line 648 C++
GUI.exe!QList<QHostAddress>::~QList<QHostAddress>() Line 622 C++
GUI.exe!main(int argc=1, char * * argv=0x003e8088) Line 17 + 0x22 bytes C++
GUI.exe!WinMain(HINSTANCE__ * instance=0x00400000, HINSTANCE__ * prevInstance=0x00000000, char * __formal=0x00151f16, int cmdShow=1) Line 131 + 0x12 bytes
GUI.exe!__tmainCRTStartup() Line 589 + 0x35 bytes C
GUI.exe!WinMainCRTStartup() Line 414 C



and windows shows the message attached with the post.

I have two network interfaces and both are connected to internet.

Can someone help me with this.

nitinkamkar
20th May 2011, 05:39
Even i have faced same issue. I am using QT 4.5.3 and VS 2005.

And in project properties -

If I change Run time Library to /MT(Multi threaded) it will work but not allowing me to debug code.

If I change Run time Library to /MDd(Multi threaded debug DLL) it will work but crashes in 64 bit machines...

I want to keep option as /MT and at same time want to debug the code..

Can any one help me?

Agroni
16th January 2013, 17:18
This problem is a result of mixing multiple MS compilers of different versions. Some of those MS compilers will set the PATH to it's own location.

To fix this problem with Qt Creator go into Projects / Build & Run / Build / Build Environment / PATH - and fix the path to use the correct path. Fix other entries too.

lclemens@gmail.com
15th October 2014, 03:06
Agroni is right... We were getting that same crash in the destructor and it turned out that the release version of QtNetwork4.lib was being used instead of QtNetworkd4.lib.