PDA

View Full Version : Simplest app with QNetworkAccessManager and First-chance exception



allexz
23rd January 2013, 21:01
Hi all,

I have created the simplest Qt (5.0.0) application using VS Add-in.
Added the simplest network request:

test.h

#ifndef TEST_H
#define TEST_H

#include <QtWidgets/QMainWindow>
#include <QtNetwork>
#include "ui_test.h"

class Test : public QMainWindow
{
Q_OBJECT

public:
Test(QWidget *parent = 0);
~Test();

public slots:
void Button_clicked();
void Request_finished(QNetworkReply *reply);

private:
Ui::TestClass ui;
};

#endif // TEST_H


test.cpp

#include "test.h"
#include <QtWidgets>

Test::Test(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
QObject::connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(Button_clicked()));

}

Test::~Test()
{

}

void Test::Button_clicked()
{
QNetworkAccessManager* manager = new QNetworkAccessManager(this);

QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(Request_finished(QNetworkReply *)));

QNetworkRequest request(QUrl("http://www.google.com"));

QNetworkReply *reply = manager->get(request);
}

void Test::Request_finished(QNetworkReply *reply)
{
reply->deleteLater();
}


main.cpp

#include "test.h"
#include "qmyapp.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Test w;
w.show();
return a.exec();
}


test.ui contains a single QPushButton pushButton.

Now if I start application and press button, then after main window destroyed I receive the following line in VS Output window:

First-chance exception at 0x74e5b9bc in Test.exe: 0x0000000D: The data is invalid.

What's wrong?
Thank you.

wysota
23rd January 2013, 21:19
Show us the debugger backtrace.

allexz
23rd January 2013, 21:46
Show us the debugger backtrace.


'Test.exe': Loaded 'W:\BB\Intaview\Test\Win32\Debug\Test.exe', Symbols loaded.
'Test.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\bin\Qt5Cored.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\ws2_32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\nsi.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\bin\icuin49.dll', Binary was not built with debug information.
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\bin\icuuc49.dll', Binary was not built with debug information.
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\bin\icudt49.dll', Binary was not built with debug information.
'Test.exe': Loaded 'C:\Windows\SysWOW64\msvcr100.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\msvcp100.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'Test.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\bin\Qt5Widgetsd.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\bin\Qt5Guid.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\bin\libGLESv2d.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\bin\D3DCompiler_43.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\bin\Qt5Networkd.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\dnsapi.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\crypt32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\msasn1.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\platforms\qminimal.d ll', Binary was not built with debug information.
'Test.exe': Unloaded 'W:\Qt\5.0.0\msvc2010\plugins\platforms\qminimal.d ll'
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\platforms\qminimald. dll', Cannot find or open the PDB file
'Test.exe': Unloaded 'W:\Qt\5.0.0\msvc2010\plugins\platforms\qminimald. dll'
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\platforms\qwindows.d ll', Binary was not built with debug information.
'Test.exe': Unloaded 'W:\Qt\5.0.0\msvc2010\plugins\platforms\qwindows.d ll'
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\platforms\qwindowsd. dll', Cannot find or open the PDB file
'Test.exe': Unloaded 'W:\Qt\5.0.0\msvc2010\plugins\platforms\qwindowsd. dll'
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\platforms\qwindowsd. dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\bin\libEGLd.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\d3d9.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\d3d8thk.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Program Files (x86)\ABBYY Lingvo x3\LvHook.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\cryptsp.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\rsaenh.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\RpcRtRemote.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Program Files\ThinkPad\Bluetooth Software\syswow64\BtMmHook.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\psapi.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\bearer\qgenericbeare r.dll', Binary was not built with debug information.
'Test.exe': Unloaded 'W:\Qt\5.0.0\msvc2010\plugins\bearer\qgenericbeare r.dll'
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\bearer\qgenericbeare rd.dll', Cannot find or open the PDB file
'Test.exe': Unloaded 'W:\Qt\5.0.0\msvc2010\plugins\bearer\qgenericbeare rd.dll'
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\bearer\qnativewifibe arer.dll', Binary was not built with debug information.
'Test.exe': Unloaded 'W:\Qt\5.0.0\msvc2010\plugins\bearer\qnativewifibe arer.dll'
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\bearer\qnativewifibe arerd.dll', Cannot find or open the PDB file
'Test.exe': Unloaded 'W:\Qt\5.0.0\msvc2010\plugins\bearer\qnativewifibe arerd.dll'
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\bearer\qgenericbeare rd.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\IPHLPAPI.DLL', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\winnsi.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\dhcpcsvc.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\dhcpcsvc6.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'W:\Qt\5.0.0\msvc2010\plugins\bearer\qnativewifibe arerd.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\wlanapi.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\wlanutil.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\mswsock.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\WSHTCPIP.DLL', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\wship6.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Program Files (x86)\Common Files\microsoft shared\Windows Live\WLIDNSP.DLL', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\rasadhlp.dll', Cannot find or open the PDB file
'Test.exe': Loaded 'C:\Windows\SysWOW64\FWPUCLNT.DLL', Cannot find or open the PDB file
'Test.exe': Unloaded 'C:\Windows\SysWOW64\wship6.dll'
'Test.exe': Unloaded 'C:\Windows\SysWOW64\WSHTCPIP.DLL'
'Test.exe': Unloaded 'C:\Program Files (x86)\Common Files\microsoft shared\Windows Live\WLIDNSP.DLL'
'Test.exe': Unloaded 'C:\Windows\SysWOW64\FWPUCLNT.DLL'
'Test.exe': Loaded 'C:\Windows\SysWOW64\WSHTCPIP.DLL', Cannot find or open the PDB file
First-chance exception at 0x74e5b9bc in Test.exe: 0x0000000D: The data is invalid.
The thread 'Win32 Thread' (0x1cb4) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xb1d8) has exited with code 0 (0x0).
The thread 'bearerThread' (0xa918) has exited with code 0 (0x0).
The thread 'Thread (pooled)' (0x8248) has exited with code 0 (0x0).
'Test.exe': Unloaded 'C:\Windows\SysWOW64\WSHTCPIP.DLL'
The thread 'Win32 Thread' (0xb164) has exited with code 0 (0x0).
The thread 'httpThread' (0x90cc) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xa3a0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xabe8) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xad20) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x22a4) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xac68) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xb3a8) has exited with code 0 (0x0).
The program '[39824] Test.exe: Native' has exited with code 0 (0x0).


P.S. I'm running under Windows 7 Pro x64.

wysota
23rd January 2013, 22:19
That's not a backtrace.

allexz
23rd January 2013, 22:29
That's not a backtrace.

I'm sorry.
Do you mean the call stack?
But it is not very informative since it happens in some system thread...



KernelBase.dll!74e5b9bc()
[Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]
KernelBase.dll!74e5b9bc()
> rpcrt4.dll!74b60e0b()
rpcrt4.dll!74b60d9a()
wlanapi.dll!6af34ed7()
rpcrt4.dll!74b2feac()
ntdll.dll!7710004d()
ntdll.dll!7710f8b1()
ntdll.dll!7710fee2()
ntdll.dll!77129e83()
ntdll.dll!7710f8b1()
KernelBase.dll!74e60a91()
KernelBase.dll!74e60a2f()
kernel32.dll!74c61194()
wlanapi.dll!6af3531d()
kernel32.dll!74c6339a()
ntdll.dll!77129ef2()
ntdll.dll!77129ec5()



Unflagged 46700 0 Main Thread Main Thread Test::~Test Normal
Unflagged 46620 0 Worker Thread Win32 Thread 7711013d Normal
Unflagged 7204 0 Worker Thread Win32 Thread 77111f26 Normal
Unflagged 7908 0 Worker Thread Win32 Thread 77111f26 Normal
Unflagged 47004 0 RPC Thread RPC Callback Thread 7710fd71 Normal
Unflagged 24856 0 Worker Thread Win32 Thread 7711013d Time Critical
Unflagged 47056 0 Worker Thread bearerThread _free_base Normal
Unflagged > 44604 0 Worker Thread Win32 Thread 74e5b9bc Normal
Unflagged 43628 0 Worker Thread httpThread 7711013d Normal
Unflagged 46252 0 Worker Thread Thread (pooled) __set_flsgetvalue Normal
Unflagged 47028 0 Worker Thread Win32 Thread 77111f26 Normal
Unflagged 46980 0 Worker Thread Win32 Thread 7710f939 Above Normal

wysota
23rd January 2013, 23:01
First of all build your app in debug mode. Second of all it seems your app reaches the destructor of Test but we have no idea what happens next. If I were to guess, I'd say you have a corrupt stack there.

allexz
24th January 2013, 00:55
First of all build your app in debug mode.

It was in debug mode... OK, I've loaded system debug symbols but it did not clear anything.
I just can't understand why it happens if I almost do not add any custom code - only a few lines of code from documentation... Something wrong with my system?
Btw, I tried to switch to Qt 4.8.4 - the same story.

Call stack:

> KernelBase.dll!_RaiseException@16() + 0x58 bytes
rpcrt4.dll!_RpcpRaiseException@4() + 0x2f bytes
rpcrt4.dll!NdrpRaisePipeException() + 0x16 bytes
rpcrt4.dll!NdrReceive() + 0x1e55 bytes
rpcrt4.dll!NdrLastAsyncReceive() + 0x2c bytes
rpcrt4.dll!NdrpCompleteAsyncClientCall() + 0x85 bytes
rpcrt4.dll!Ndr64pCompleteAsyncCall() + 0x67 bytes
rpcrt4.dll!_RpcAsyncCompleteCall@8() + 0x1e bytes
wlanapi.dll!_ClientRpcCallback@12() + 0xa0 bytes
rpcrt4.dll!I_RpcAPCRoutine() + 0x2c bytes
ntdll.dll!_KiUserApcDispatcher@16() + 0x25 bytes
kernel32.dll!_WaitForSingleObjectExImplementation@ 12() + 0x43 bytes
wlanapi.dll!_NotificationApcThreadProc@4() + 0x54 bytes
kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes
ntdll.dll!___RtlUserThreadStart@8() + 0x27 bytes
ntdll.dll!__RtlUserThreadStart@8() + 0x1b bytes

Threads:

Unflagged 47848 0 Main Thread Main Thread QPushButton::`scalar deleting destructor' Normal
Unflagged 48388 0 Worker Thread _TppWaiterpThread@4 _ZwWaitForMultipleObjects@20 Normal
Unflagged 47932 0 Worker Thread _TppWorkerThread@4 _NtWaitForWorkViaWorkerFactory@8 Normal
Unflagged 48856 0 Worker Thread _TppWorkerThread@4 _NtWaitForWorkViaWorkerFactory@8 Normal
Unflagged 31392 0 RPC Thread RPC Callback Thread CROIDTable::WorkerThreadLoop Normal
Unflagged 48988 0 Worker Thread _timeThread@4 _ZwWaitForMultipleObjects@20 Time Critical
Unflagged 43132 0 Worker Thread bearerThread _NtWaitForSingleObject@12 Normal
Unflagged > 45812 0 Worker Thread _NotificationApcThreadProc@4 _RaiseException@16 Normal
Unflagged 49048 0 Worker Thread httpThread _ZwWaitForMultipleObjects@20 Normal
Unflagged 48496 0 Worker Thread Thread (pooled) _NtWaitForSingleObject@12 Normal
Unflagged 49036 0 Worker Thread _TppWorkerThread@4 _NtWaitForWorkViaWorkerFactory@8 Normal
Unflagged 48080 0 Worker Thread _SockAsyncThread@4 _ZwRemoveIoCompletion@20 Above Normal
Unflagged 48172 0 Worker Thread Win32 Thread _ZwWaitForMultipleObjects@20 Normal
Unflagged 48000 0 Worker Thread _TppWorkerThread@4 _NtWaitForWorkViaWorkerFactory@8 Normal

wysota
24th January 2013, 01:36
Is what you posted earlier a complete app you're testing on right now?

allexz
24th January 2013, 02:49
Is what you posted earlier a complete app you're testing on right now?

Yes! Nothing more! Just a clear project with one button and simple network request.

wysota
24th January 2013, 06:22
Try setting a breakpoint in destructor of Test and step through the code to see when it crashes.

allexz
24th January 2013, 12:54
I found one interesting thing. If I set breakpoint in the destructor of Test class, wait few seconds and continue execution - the exception is not raised.
Looks like some resources don't have time to be freed...

wysota
24th January 2013, 15:17
Since the very beginning I was suspecting some problem with threads which could explain what is going on. However you said the code you posted was a complete testbed so the only threads running are those related to QNetworkAccessManager. Or at least that should be the case. On the other hand we can see around 10 threads in your app. Where are they coming from? Are you sure there is no additional code involved? Are you linking with some external libraries or something like that? Where does qmyapp.h come from?

allexz
24th January 2013, 18:40
On the other hand we can see around 10 threads in your app. Where are they coming from?

I wonder myself...


Are you sure there is no additional code involved? Are you linking with some external libraries or something like that? Where does qmyapp.h come from?

Yes, I'm sure. qmyapp.h - it contained custom QApplication derived class, but now I don't use it. I even removed it from the project - nothing changed.
Input libraries: qtmaind.lib;QtCored4.lib;QtGuid4.lib;QtNetworkd4.l ib;

OK, thank you anyway!

pke
30th August 2013, 13:26
Did you solve this? I am running into the exact same problem in my code. Same stacktrace, same simple code, just a get() call with the QNAM. And its 100% reproducible.

crioux
30th August 2013, 15:58
I get this error as well, without even using the QNAM. It's loading 'qnativewifibearerd' and then crapping out in it after it tries to to call 'closeHandle'.
My stack trace looks nearly the same.

--chris

ChrisW67
30th August 2013, 20:59
@pke: Are you using exactly the posted code without the customised QApplication, VS2010, and Qt 5.0.0? If so, upgrade your Qt and do a clean build.

@crioux: So you are crashing in this fashion with a program that contains nothing except a QApplication instantiation and Designer Ui. Forgive me if I do not trust that assertion. Do a complete rebuild. Post a single file example and complete version details if the problem persists.

abc100m
5th September 2013, 16:11
I have the same issue, QNetworkAccessManager cause a debug output like :
test.exe .. 0x74fcb727 .....: 0x0000000D: The data is invalid


my test environment is :

window 7 64 bit
visual studio 2008
Qt 5.1

wysota
5th September 2013, 16:30
I have the same issue,
How do you know it is the same issue?

abc100m
5th September 2013, 17:13
I want to reproduce this issue, but same character is Chinese.

Ok, I change a bit code that provide by #1. I create a new Qt project, and have two button:

void Test::Request_finished(QNetworkReply *reply)
{
//reply->deleteLater();
}

void Test::Button_clicked()
{
manager = new QNetworkAccessManager(this);

QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(Request_finished(QNetworkReply *)));
QNetworkRequest request(QUrl("http://www.google.com"));
reply = manager->get(request);
}

void Test::destroy_clicked()
{
qDebug() << "to delete reply...";
if (reply)
{
reply->abort();
delete reply;//->deleteLater();
reply = NULL;
}

qDebug() << "to delete manager...";
if (manager)
{
delete manager;
manager = NULL;
}

qDebug() << "reply, manager destroyed...";
}

now, I begin to debug my test program in visual studio IDE(just F5).

after the program is run, I break it to see how many threads, and now just have 6 threads:
--------
0 > 3012 主线程 主线程 _free_base æ*£å¸¸ 0
0 1228 RPC 线程 RPC 回调线程 7739fd81 æ*£å¸¸ 0
0 6636 辅助线程 Win32 线程 773a014d æ*£å¸¸ 0
0 5628 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 5948 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 6696 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
------------------

now I click button1 to execute void Test::Button_clicked(), after executed I see there 14 threads:
---------------------
0 > 3012 主线程 主线程 _free_base æ*£å¸¸ 0
0 1228 RPC 线程 RPC 回调线程 7739f8c1 æ*£å¸¸ 0
0 5928 辅助线程 Win32 线程 7739f8c1 æ*£å¸¸ 0
0 7972 辅助线程 Win32 线程 7739f949 高于æ*£å¸¸ 0
0 5632 辅助线程 Win32 线程 773a014d 时间关键 0
0 6636 辅助线程 Win32 线程 773a014d æ*£å¸¸ 0
0 4404 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 5528 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 5628 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 6260 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 6696 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 6640 辅助线程 Qt HTTP thread QMetaObject::activate æ*£å¸¸ 0
0 8092 辅助线程 Qt bearer thread QMetaObject::activate æ*£å¸¸ 0
0 4496 辅助线程 Thread (pooled) QWaitConditionPrivate::wait æ*£å¸¸ 0
---------------------

and these time I click button2 to execute void Test::destroy_clicked(), after execute I see there 10 threads left:
---------------------
0 > 3012 主线程 主线程 _free_base æ*£å¸¸ 0
0 5928 辅助线程 Win32 线程 7739f8c1 æ*£å¸¸ 0
0 5632 辅助线程 Win32 线程 773a014d 时间关键 0
0 6636 辅助线程 Win32 线程 773a014d æ*£å¸¸ 0
0 3092 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 4060 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 5528 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 5628 辅助线程 Win32 线程 773a1f36 æ*£å¸¸ 0
0 4912 辅助线程 qt_adopted_thread_watcher_function QArrayData::data æ*£å¸¸ 0
0 8092 辅助线程 Qt bearer thread QMetaObject::activate æ*£å¸¸ 0
---------------------------

after about 1 minute, I close the test program, and the visual studio debug window shows:
--------------------------
to delete reply...
to delete manager...
线程 'Qt HTTP thread' (0x19f0) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
reply, manager destroyed...
线程 'Win32 线程' (0xc14) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
线程 'Win32 线程' (0x15fc) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
test.exe ä¸*çš„ 0x74fcb727 处最可能的异常: 0x0000000D: The data is invalid
线程 'Win32 线程' (0x1728) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
线程 'qt_adopted_thread_watcher_function' (0x1330) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
线程 'Qt bearer thread' (0x1f9c) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
线程 'Win32 线程' (0x1600) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
线程 'Win32 线程' (0x1338) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
线程 'Win32 线程' (0x1598) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
线程 'Win32 线程' (0xfdc) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
线程 'Win32 线程' (0x19ec) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
线程 'Win32 线程' (0xe9c) å·²é€€å‡ºï¼Œè¿”å›žå€¼ä ¸º 0 (0x0)。
程序“[4784] test.exe: æœ¬æœºâ€å·²é€€å‡ºï¼Œè¿ ”回值为 0 (0x0)。
------------------------------------------------

wysota
5th September 2013, 17:17
Your code goes way past an empty project with an instance of QNetworkAccessManager that does nothing.

If your back trace is different than OP's then please start your own thread instead of hijacking this one.

abc100m
5th September 2013, 17:29
Different back trace but have the same result, :)

For test this case, I create a new Visual Studio project, and my test code list below. May be someone can test this code


//test.h
#ifndef TEST_H
#define TEST_H

#include <QtWidgets/QMainWindow>
#include <QtNetwork>
#include "ui_test.h"


class Test : public QMainWindow
{
Q_OBJECT

public:
Test(QWidget *parent = 0);
~Test();

public slots:
void Button_clicked();
void destroy_clicked();
void Request_finished(QNetworkReply *reply);

private:
Ui::TestClass ui;
QNetworkReply* reply;
QNetworkAccessManager* manager;
};

#endif // TEST_H


//test.cpp
#include "test.h"
#include <QtWidgets>

Test::Test(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
QObject::connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(Button_clicked()));
QObject::connect(ui.btn_destroy, SIGNAL(clicked()), this, SLOT(destroy_clicked()));

reply = NULL;
manager = NULL;
}

Test::~Test()
{
}

void Test::Request_finished(QNetworkReply *reply)
{
//reply->deleteLater();
}

void Test::Button_clicked()
{
manager = new QNetworkAccessManager(this);
QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(Request_finished(QNetworkReply *)));
QNetworkRequest request(QUrl("http://www.google.com"));
reply = manager->get(request);
}

void Test::destroy_clicked()
{
qDebug() << "to delete reply...";
if (reply)
{
reply->abort();
delete reply;//->deleteLater();
reply = NULL;
}

qDebug() << "to delete manager...";
if (manager)
{
delete manager;
manager = NULL;
}

qDebug() << "reply, manager destroyed...";
}