Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QtNetwork and OpenSSL threading...
Didier M. last edited by Didier M.
I have what seems like a deadlock issue in my app, which of course only happens in release and disappears as soon as I try to add any kind of debugging logging or code. I’m posting here in the hope that someone can maybe share a similar experience or suggest an avenue I can use to try and figure out the cause of the problem. This will also lay out my assumptions, some of which may be misguided.
I’m currently using Qt 5.12.4 and I see the deadlock on macOS 10.14 and 10.15. I use QtNetwork to download a receipt from a web server via https. I assume this uses OpenSLL to do so. I assume that would be the dylib installed on the machine itself since I do not ship any other OpenSSL dylib with my app.
The receipt’s signature is then tested using OpenSLL in my app directly.l I’m assuming this is using the same OpenSSL dylib that Qt uses since, again, I do not have any other linked that I know of.
I’m aware that OpenSSL (at least pre 1.1.1) is not meant to be thread-safe when using its objects. I had a crash in my app that took place in an assertion in the std::recursive_mutex destructor from inside the openSSL library. I assume that somehow this meant that my app was using OpenSSL on multiple threads (which is was even though it was doing do on different objects) so I decided to be safe and I forced all my own OpenSSL calls to be from the main thread. This is the point where this deadlock started happening.
Now, I’m not 100% sure it’s a real deadlock. The app just hangs on init at the point where it seems like QtNetword would do the QNetworkManager post call to download the receipt. Again, not 100% sure of the spot since I can’t add debug logs or the app doesn’t lock up anymore.
Does this ring a bell for anyone on interactions between QTNetwork and OpenSSL? Anyone can suggest something I can try to get more info on where the issue comes from? Any ideas appreciated.
Did you build Qt yourself ? Because otherwise, Qt doesn't use OpenSSL on macOS since a long time. It uses the SecureTransport framework.
Didier M. last edited by
I'm using the commercial binaries so this definitely helps clarify my assumptions. I was assuming OpenSSL because the Windows commercial binaries seem to use OpenSSL but I guess I never bothered to verify this.
So my deadlock/issue is somewhere else. Thanks for the quick help!
Just in case, try checking with 5.13.1 and 5.12.5. Maybe something changed in between and your issue might already be solved.