Solved Crash after moving from Qt 5.9 to Qt 5.12
-
Hi everybody!
I'm working on a porting from Qt 5.9.7 to Qt 5.12.5 . The application is connected to a db sqlite and it uses a QSqlDatabase class.
When using Qt 5.12.5, I see a crash in QSqlQuery prepare or in the exec methods. I tried to print the queries and every time the application crash in a different one. The queries seems to be correct.
In a deeper analysis, I saw that the same database connection is used in 2 threads at the same time (2 select queries) and I think this is the cause of the crash because the threads cannot share the connection (https://stackoverflow.com/questions/47457478/using-qsqlquery-from-multiple-threads).My answer is: why did this never happen in Qt 5.9.7? Could be connected to the porting?
Best regards!
Fabio -
@FaCal said in Crash after moving from Qt 5.9 to Qt 5.12:
why did this never happen in Qt 5.9.7?
Because in 5.9 the thread check was not there and you got rare race conditions now and then.
-
@FaCal
As per the docs, you are indeed correct that you must not attempt to use a connection from different threads.I don't imagine anyone will know specifically why you got away with it in one version of Qt but not in another. That's what threading issues can be like.
-
Thank you a lot!
BR
Fabio