Details
-
Bug
-
Resolution: Cannot Reproduce
-
P1: Critical
-
None
-
6.2.2
-
None
-
Windows 10, MSVC 2019
Description
The code to reproduce the bug:
struct Cfg { QString drv, qname, host; int port; QString name, user, pass; }; void createDestroyDb(const Cfg& c) { bool ok = false; QSqlDatabase d; for(;;) { d = QSqlDatabase::addDatabase(c.drv, c.qname); if(!d.isValid()) break; d.setHostName(c.host); d.setPort(c.port); d.setDatabaseName(c.name); d.setUserName(c.user); d.setPassword(c.pass); { /*static QMutex m; QMutexLocker l(&m);*/ ok = d.open(); } break; } // The QMutex hack suppresses the bug. if(!ok) qWarning().noquote() << d.lastError().text(); d = {}; QSqlDatabase::removeDatabase(c.qname); } void f() { std::vector<QString> v({"db1", "db2"}); QtConcurrent::blockingMap(v, [](const QString& s) { createDestroyDb({"QPSQL", s, "wronghost", 5432, "db", "user", "pass"}); }); qInfo("No crash happened."); } int main(int ac, char* av[]) { qSetMessagePattern("[%{if-warning} - - - WARN %{endif}%{time HHmmss.zzz} %{file}:%{line} %{function} %{threadid}] %{message}"); QCoreApplication app(ac, av); QTimer::singleShot(0, [&] { f(); app.quit(); }); return app.exec(); }