[Qt-interest] Crash in QNetworkInterface::allAddresses()

Devendra Patel devpatel82 at gmail.com
Mon Jan 24 07:12:10 CET 2011


Hi all,

*My Setup*
I am using Precompiled libs for VS2008, Qt version 4.6.2 with Visual Studio
2005 on Win XP machine. Qt addin version is 1.14

I am trying to run the following code

#include "gui.h"
#include <QtGui/QApplication>
#include <QtNetwork>
#include <Windows.h>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    GUI w;
    QList<QHostAddress> list=QNetworkInterface::allAddresses();
    //QList<QNetworkInterface> l=QNetworkInterface::allInterfaces();
    QHostAddress host;
    foreach(host,list)
    {
        if(!(host==QHostAddress::LocalHost) && !(host==QHostAddress::Any) &&
!(host==QHostAddress::Null))
        {
            qDebug("%s\n",host.toString().toAscii().data());
        }
    }
    w.show();
    return a.exec();
}

The only changes I made is in main.cpp. All other files are same as the Qt
GUI project wizard creates. GUI comes up fine but it crashes when I try to
close the main window. It seems that the crash happens in destructor of
QHostAddress. To reproduce this you can simply write following code

*QList<QNetworkInterface> list= QNetworkInterface
<http://doc.qt.nokia.com/latest/qnetworkinterface.html>::allInterfaces();*

and you should see the crash when 'list' goes out of scope (it only happens
if you have setup similar to mine).

I have attached the message which I see from VS.

and the *stack trace *is as below

     msvcr80d.dll!operator delete(void * pUserData=0x00b848a0)  Line 52 +
0x51 bytes    C++
     GUI.exe!QHostAddress::`scalar deleting destructor'()  + 0x21 bytes
C++
     GUI.exe!QList<QHostAddress>::node_destruct(QList<QHostAddress>::Node *
from=0x00b85034, QList<QHostAddress>::Node * to=0x00b85058)  Line 402 + 0x2f
bytes    C++
     GUI.exe!QList<QHostAddress>::free(QListData::Data * data=0x00b85020)
Line 648    C++
     GUI.exe!QList<QHostAddress>::~QList<QHostAddress>()  Line 622    C++
     GUI.exe!main(int argc=1, char * * argv=0x003e6b80)  Line 21 + 0x22
bytes    C++
     GUI.exe!_WinMain at 16()  + 0xb8 bytes
     GUI.exe!__tmainCRTStartup()  Line 589 + 0x35 bytes    C
     GUI.exe!WinMainCRTStartup()  Line 414    C
     kernel32.dll!7c817077()
     [Frames below may be incorrect and/or missing, no symbols loaded for
kernel32.dll]

I tried to investigate more on  this issue and below is my finding.

1) I don't see any crash if I create qt console application using VS 2005.
2) I don't see any crash if I create GUI application using Qt Creator.

This is something to do with VS2005. Is it because I am using Precompiled
libs for VS2008 or is it a bug.
Has anyone come across similar issue?

Thanks
-- 
Blog
http://observe-read-think.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110124/d4074fc9/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Qt_Crash.PNG
Type: image/png
Size: 10133 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110124/d4074fc9/attachment.png 


More information about the Qt-interest-old mailing list