[Interest] Crash when creating QNetworkAccessManager in qt 5.14.x

maitai maitai at virtual-winds.org
Wed Feb 5 16:32:33 CET 2020


Hi Rainer, 

Unfortunately your suggestion didn't work 

I have added in my pro file:

win32: QMAKE_LFLAGS += /CLRTHREADATTRIBUTE:MTA

and I can see the option in the link command (I also tried the 2 other
possibilities STA and NONE of course), but that does not fix anything.

My feeling is that it does not come from CoInitializeEx() finally,
because anyway in regular builds we are calling it at the very beginning
of main, before creating QApplication or QNetworkManager, so the
threading model should be already determined.

@Mårten 

I have never succeeded to get a stack trace or to debug with
Windows/MSVC, sorry (I usually debug stuff under Linux only). 

I have tried a build with MINGW64 instead of MSVC in the hope I will be
able to get a trace, but as one can expect... no crash in that case. 

Philippe

Le 05-02-2020 11:53, Rainer Wiesenfarth a écrit :

>> [...]
> 
>> That being said, even if I remove this call and all references to WMI code and CoInitializeEx (including the links to wbemuuid and ws2_32), it still crashes if i do not create QNetworkManager before QApplication...
> 
>> [...]
> 
> Our experience is that only the first call to CoInitializeEx() succeeds and that subsequent calls with a different threading model fail. 
> 
> That being said, I _assume_ that *both*, QNetworkManager and QApplication reach a call to CoInitializeEx() somewhere deep down the code (e.g. in a loaded plugin or even an Explorer extension), and these two calls differ in the selected threading model. For your application the two cases are: 
> 
> QNetworkManager before QApplication: QNetworkManager initializes its desired threading model, the call to CoInitializeEx() in QApplication fails, but does not cause any harm. 
> 
> QApplication before QNetworkManager: QApplication initializes its desired threading model, the call to CoInitializeEx() in QNetworkManager fails and causes a crash. 
> 
> To avoid the call to QNetworkManager before QApplication, you should probably use the /CLRTHREADATTRIBUTE:{MTA,STA,NONE} linker flag (in VS: Linker - Advanced - CLR Thread Attribute) with the correct value for your case. 
> 
> Cheers, Rainer 
> -- 
> 
> Software Engineer | Trimble Imaging Division
> Rotebühlstraße 81 | 70178 Stuttgart | Germany
> Office +49 711 22881 0 | Fax +49 711 22881 11
> http://www.trimble.com/imaging/ | http://www.inpho.de/
> 
> Trimble Germany GmbH, Am Prime Parc 11, 65479 Raunheim
> Eingetragen beim Amtsgericht Darmstadt unter HRB 83893,
> Geschäftsführer: Rob Reeder, Jürgen Kesper 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200205/4a0aaa4b/attachment.html>


More information about the Interest mailing list