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

QUuid does not return unique id's on Ryzen 3rd generation CPU

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 5.13.0
    • Core: Other
    • None
    • Linux/X11

    Description

      On a system with a AMD Ryzen 7 3700X 8-Core Processor, QUuid does not return unique uuid's. Given the following example code:

       

      #include <QCoreApplication>
      #include <QUuid>
      
      #include <iostream>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          std::cout << QUuid::createUuid().toString().toStdString() << std::endl;
          std::cout << QUuid::createUuid().toString().toStdString() << std::endl;
          std::cout << QUuid::createUuid().toString().toStdString() << std::endl;
          std::cout << QUuid::createUuid().toString().toStdString() << std::endl;
          std::cout << QUuid::createUuid().toString().toStdString() << std::endl;
          std::cout << QUuid::createUuid().toString().toStdString() << std::endl;
      
          return a.exec();
      }
      

      results in:

      $ ./qtcreator_test 
      {ffffffff-ffff-4fff-bfff-ffffffffffff}
      {ffffffff-ffff-4fff-bfff-ffffffffffff}
      {ffffffff-ffff-4fff-bfff-ffffffffffff}
      {ffffffff-ffff-4fff-bfff-ffffffffffff}
      {ffffffff-ffff-4fff-bfff-ffffffffffff}
      {ffffffff-ffff-4fff-bfff-ffffffffffff}

      CPU instruction example:

      #include <stdio.h>
      #include <stdint.h>
      
      int rdrand64_step (uint64_t *rand)
      {
          unsigned char ok;    
          asm volatile ("rdrand %0; setc %1"
              : "=r" (*rand), "=qm" (ok));    
          return (int) ok;
      }
      
      int main(void)
      {
          int tries = 10;
          uint64_t rv;
          while (tries--)
          {
              int r = rdrand64_step(&rv);
              printf("%d: %ld\n", r, rv);
          }
      }
      

      results in:

      $ ./rdrand 
      1: -1
      1: -1
      1: -1
      1: -1
      1: -1
      1: -1
      1: -1
      1: -1
      1: -1
      1: -1
      

      See also: https://github.com/systemd/systemd/issues/11810 but this issue is not related to suspending.

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              maaike Maaike Z
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes