Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
None
-
5.15.1
-
None
Description
After updating from Qt 5.12.9 to 5.15.1, part of our multithreaded code which accesses QDate::FromString started firing a Q_ASSERT in qcalendar.cpp non determinstically, line 103. After debugging into Qt source code, the problem is with the global static calendar registry:
Q_GLOBAL_STATIC(Registry, calendarRegistry);
This registry is accessed concurrently when QDate::FromString is called, and the assert Q_ASSERT(byId[size_t(id)] == nullptr) fails whenever QDate::FromString is called using default calendar parameter which makes sense, since there is already a gregorian default calendar in registry.
Sample code to reproduce:
class HelloWorldTask : public QRunnable { void run() override { QDate::fromString("2017-12-21", "yyyy-MM-dd"); } }; for(int i = 0; i < 40 ; ++i) { HelloWorldTask *hello = new HelloWorldTask(); QThreadPool::globalInstance()->start(hello); } QThreadPool::globalInstance()->waitForDone();
We worked around the problem using a constant global static QCalendar object which is passed as the last parameter in QDate::FromString
Thanks
Attachments
Issue Links
- duplicates
-
QTBUG-84575 QCalendar class is not reentrant
-
- Closed
-
For Gerrit Dashboard: QTBUG-88815 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
309673,14 | Make QCalendar's backend registration reentrant-safe | dev | qt/qtbase | Status: MERGED | +2 | 0 |
331253,2 | Make QCalendar's backend registration reentrant-safe | 6.0 | qt/qtbase | Status: MERGED | +2 | 0 |
331255,2 | Make QCalendar's backend registration reentrant-safe | tqtc/lts-5.15 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |