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

Regression: QCache crash

    XMLWordPrintable

    Details

    • Platform/s:
      All
    • Commits:
      8c5e31536a (qt/qtbase/dev) 8c5e31536a (qt/tqtc-qtbase/dev) bf02126e39 (qt/qtbase/6.2.3) bf02126e39 (qt/tqtc-qtbase/6.2.3) 9681c208d2 (qt/qtbase/6.3) 9681c208d2 (qt/tqtc-qtbase/6.3) 8bdfb47f8b (qt/qtbase/6.2) 8bdfb47f8b (qt/tqtc-qtbase/6.2)
    • Sprint:
      Team Two Foundation Sprint 49

      Description

      The example below fails quickly:

       

      #include <QCache>
      #include <QCoreApplication>
      #include <QRandomGenerator>
      #include <QUuid>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          QList<QString> set1{
              // hash 12997127560409977849
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1607682889889.jpg?width=246&height=357",
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1607680491432.jpg?width=246&height=357"};
          QList<QString> set2{
              // hash 3776740375027953557
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1607690988464.jpg?width=246&height=357",
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1607692568848.jpg?width=246&height=357",
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1607690163139.jpg?width=246&height=357"};
          QList<QString> set3{
              // hash 9098347284464799501
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1598348229353.jpg?width=246&height=357",
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster15k98347394491.jpg?width=246&height=357",
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1598347441419.jpg?width=246&height=357"};
          QList<QString> set4{
              // hash 12229382533688088545
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1564750010324.jpg?width=246&height=357",
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1564753002916.jpg?width=246&height=357"};
          QList<QString> set5{
              // hash 4785817326207999282
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1548234017423.jpg?width=246&height=357",
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1548233337244.jpg?width=246&height=357",
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1548231760481.jpg?width=246&height=357",
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1548232389457.jpg?width=246&height=357",
              "https://msk-m10-itv01.svc.iptv.rt.ru/sdp/nc-poster1548238548599.jpg?width=246&height=357"};
      
          QList<QList<QString> *> sets{&set1, &set2, &set3, &set4, &set5};
      
          QCache<QString, int> c;
          c.setMaxCost(1024 * 1024);
      
          for (;;) {
              const auto n = QRandomGenerator::global()->bounded(0, 5);
              const auto i = QRandomGenerator::global()->bounded(0, sets.at(n)->size());
              const auto cost = QRandomGenerator::global()->bounded(1024, 32000);
              const auto &key = sets.at(n)->at(i);
              if (c.contains(key)) {
                  const auto dummy = *c.object(key);
                  Q_UNUSED(dummy)
              } else {
                  c.insert(key, new int(0), cost);
              }
      
              c.insert(QUuid::createUuid().toString(), new int(0),
                       QRandomGenerator::global()->bounded(1024, 32000));
          }
      
          return a.exec();
      }
      

      Sets contain strings with the same hash value.

        Attachments

        1. 1.png
          1.png
          269 kB
        2. 2.png
          2.png
          278 kB

          Issue Links

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

            Activity

              People

              Assignee:
              manordheim Mårten Nordheim
              Reporter:
              maksimshapovalov Maksim Shapovalov
              PM Owner:
              Vladimir Minenko Vladimir Minenko
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes