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

Race in QTime::toString

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Duplicate
    • Affects Version/s: 5.14.2
    • Fix Version/s: None
    • Component/s: Core: Date/Time
    • Labels:
      None
    • Platform/s:
      Windows
    • Story Points:
      13

      Description

      We're seeing a crash while using QTime::toString. From what I can work out so far, it seems to be coming from the fact that there appears to be a race in there.

      We crash here: https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/time/qcalendar.cpp#n92

      And this is in code that will have multiple (of the order of 10) threads doing the same QTime::toString but on different QTime objects at the same time.

      From digging around, it looks like especially if this all happens to be the first time the QGregorianCalendar needs to be instantiated, then there will be races with multiple threads constructing the gregorian calendar and trying to insert it into the registry.

      I've attached a sample project that shows a tonne of asserts being thrown if you run it in debug mode. Sadly I haven't managed to make it crash in the same manner as we have when I run in release mode. However the asserts in debug lead me to believe that this is worth reporting anyway while I continue to try and replicate our exact crash.

      Now, it might be that you just say that QTime::toString is not thread safe (or rather QLocale is not) but from e.g. QTBUG-49473 it appears that you do want QTime::toString to be thread-safe. So I figured let's report this and get some thoughts.

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              Eddy Edward Welbourne
              Reporter:
              mattjgalloway Matt Galloway
              PM Owner:
              Maurice Kalinowski Maurice Kalinowski
              RnD Owner:
              Alex Blasche Alex Blasche
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: