Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Not Evaluated
-
Resolution: Fixed
-
Affects Version/s: 5.12.0
-
Fix Version/s: 5.13.0 Alpha 1
-
Component/s: Core: Date/Time
-
Labels:None
-
Platform/s:
-
Commits:d5891036de4622e18cf4d68750610224ad201ee0
Description
Function QDateTime::toString(const QString& format) is not reentrant.
It crashes if use this function in multi-thread application, even with own instances of QDateTime.
Example:
#include <QCoreApplication> #include <thread> #include <QDateTime> void func() { QDateTime dt = QDateTime::currentDateTimeUtc(); for (int i = 0; i < 1000000; i++) QString s = dt.toString(QStringLiteral("hh:mm:ss.zzz")); } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); std::thread t1(func); std::thread t2(func); std::thread t3(func); t1.join(); t2.join(); t3.join(); return a.exec(); }