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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 28 19:10:22 UTC 2019


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #1 from Dlang Bot <dlang-bot at dlang.rocks> ---
@n8sh created dlang/phobos pull request #6985 "Fix Issue 19836 - Excessive
probability of UUID collisions in std.uuid.randomUUID" fixing this issue:

- 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