Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74448

Function QDateTime::toString(const QString& format) is not reentrant

    XMLWordPrintable

    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:
      Windows
    • 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();
      }
      
      

       

       

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            Eddy Edward Welbourne
            Reporter:
            serhiy Serhiy Malokhatko
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes