Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.12
-
None
Description
Qt will be used in a plug-in (dll). The plug-in will be created and deleted on the main-thread of a host. But a functon of the plug-in will be called in a Non-Qt-Worker-Thread. In that call QThread::currentThread () will be used. All is fine. Finally the plug-in will be released (FreeLibrary) and the host will be closed. But after that, the application will crash.
We found that the problematic part happens here ...
// qthread_win.cpp
DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
ret = WaitForMultipleObjects(handlesCopy.count(), handlesCopy.constData(), false, INFINITE);
... it waits and will never get through that point.
The problem - it seems to be - is that the creation of qt_adopted_thread_watcher_function happens inside the Non-Qt-Thread. And the design expects that this Non-Qt-Thread will be finished before the plug-in will be removed. But that's not possible. The plug-in creation goes like this
- Start Host
- Start Non-Qt-Worker-Thread
- Load Plug-In
- Call Plug-In call from a Worker-Thread
- Remove Plug-In
- Stop Non-Qt-Worked-Thread
- Close Host
I've attached a example to get a picture of the problem. The example has a host and a plug-in. Just compile the lib and the app and run the app. Wait 5 seconds and you will see the crash. A screenshot of the crash is also attached.
Thank you very much for taking your time to look into it.