[Issue 19836] Excessive probability of UUID collisions in std.uuid.randomUUID

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 29 07:50:16 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19836

Dlang Bot <dlang-bot at dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Dlang Bot <dlang-bot at dlang.rocks> ---
dlang/phobos pull request #6985 "Fix Issue 19836 - Excessive probability of
UUID collisions in std.uuid.randomUUID" was merged into master:

- 5d0f1d3471b95d6d22406001f3e7ba52b4691aa2 by Nathan Sashihara:
  Fix Issue 19836 - Excessive probability of UUID collisions in
std.uuid.randomUUID

  On 64-bit architectures use 64 bits of entropy to initialize
  thread-local `rndGen`.

  The motivation for this change is std.uuid defaults to using `rndGen`
  to generate UUIDs. If every `rndGen` starts in one of 2^^32 states then
  if 77000 independent programs each generate a single UUID there is a 50%
  chance that at least two of them generate the same initial UUID (and all
  subsequent UUIDs would be identical as well). Not just Phobos but also
  C++ boost::uuids::random_generator defaults to generating UUIDs with a
  Mersenne Twister initialized from a 32-bit seed, exacerbating the
  collision problem further. If instead there are 2^^64 possible initial
  states of `rndGen` there can be over 5 billion independent `rndGen`s
  before there is a 50% chance of two having identical initial states.

  This change is limited to 64-bit architectures to avoid a measurable
  performance decrease, because many programs are not generating UUIDs.

https://github.com/dlang/phobos/pull/6985

--


More information about the Digitalmars-d-bugs mailing list