Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.4, 5.10.1
-
None
-
Windows 10 64bit
MSVC Qt 5.10.1 32bit
MSVC Qt 5.9.4
Description
I think I found a weird issue while trying to get Visual Leak Detector and Windows CRT collecting the results when shutting down the app with latest Qt version 5.10.1. I created a minimal example that reproduces the issue that I attached. This happens in both debug and release under Windows 10 using MSVC 2015 and Qt 5.10.1 32bit. I was also able to reproduce using MSVC 2015 Qt 5.9.4 32bit as well.
The idea is simple: just have a global variable in a shared library. I expect the destructor to be called when the library is unloaded when exiting the application. However, that doesn't happen if I call `QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)` or if I send an HTTP(s) request. Apart from setting a log trace, I have also verified that if I set a breakpoint, it doesn't get hit.
For instance, in my example this is what happens when I don't call `availableDevices`:
Lib::Lib() Lib::foo Using Qt version 5.10.1 Lib::~Lib()
Then, calling `availableDevices`:
Lib::Lib() Lib::foo Using Qt version 5.10.1 "Speakers (High Definition Audio Device)" "Speakers (High Definition Audio Device)"
This same code works as expected and the destructor is called in Linux, macOS and under Windows using MinGW 5.3.0 Qt 5.10.1 32bit. So, it seems it only affects MSVC. Something interesting is that if instead of linking at compile time I do load the library at runtime using `LoadLibrary`, the destructor is properly called. I imagine this is because the `FreeLibrary` for my shared library is called automagically (and thus, the destructor of my global variable) before something else happens which causes the app to exit not gracefully.