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

QUuid::createUuid does not seed the random number generator in certain situations

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 4.7.0, 4.7.1
    • 4.6.2
    • Core: Threads
    • None
    • 2ef8b92ececbf9d33d7c0b44f46c7c975fb0fdaa, a0fffeed6fceb8244328b649a3f6feb520493bc2, a736d333aab9e2e97fdbb738b3f3f4646afe192e, a736d333aab9e2e97fdbb738b3f3f4646afe192e, f28a27987fa4e1b2faa1c57188c128afb735f70a

    Description

      QUuid::createUuid does not seed the random number generator in certain cases, as the documentation says it should. This results in QUuid::createUuid creating an identical sequence of uuids from one process instance to the next.

      To reproduce:

      Run the attached test program several times. You can space out the program runs or seconds, minutes, or hours; it does not matter (i.e., this issue is distinct from QTBUG-8374)

      Expected: A different sequence of uuids on each run.

      Actual: An identical sequence of uuids.
      An example run, along with the time the program was run:
      $ date && ./test
      Thu Jun 3 11:12:21 EDT 2010
      "

      {b7203c47-06bf-4878-9ff5-6afffb2db546}"
      "{aae9945b-f354-4d84-bb4e-64e588a89635}"
      "{3faefaa6-b843-4363-9967-f3a5e3308339}"
      $ date && ./test
      Thu Jun 3 11:38:50 EDT 2010
      "{b7203c47-06bf-4878-9ff5-6afffb2db546}

      "
      "

      {aae9945b-f354-4d84-bb4e-64e588a89635}"
      "{3faefaa6-b843-4363-9967-f3a5e3308339}"
      $ date && ./test
      Thu Jun 3 14:14:09 EDT 2010
      "{b7203c47-06bf-4878-9ff5-6afffb2db546}"
      "{aae9945b-f354-4d84-bb4e-64e588a89635}

      "
      "

      {3faefaa6-b843-4363-9967-f3a5e3308339}

      "

      More information:

      • The problem will go away if the test program's call to qrand() is commented-out. Debugging into QUuid::createUuid, qsrand(), and qrand(), you will see how the call sequence in the test program results in the random number generator not being seeded.
      • This is a regression. The test program behaves as expected with Qt 4.5.2.
      • This appears to be an unintended consequence of commit 90a082c9, which is a fix for QTBUG-3543.
      • This issue was discovered in a production application where the problematic call to qrand() was not made by application code, but by QMapData::node_create.

      Attachments

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

        Activity

          People

            bhughes Bradley T. Hughes (closed Nokia Identity) (Inactive)
            chrisgics Christopher Gaal
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes