9

I've managed to successfully reproduce the same GUID (yes, you read that correctly) using a simple C#.NET scratch program when reverting snapshots inside VMWare. The client virtual machine is Windows Server 2008 R2 64-bit. I've tried Windows XP and Windows 7 64-bit clients with unsuccessful results. The version of VMWare I'm using is 6.5.3 build-185404. All I do is revert to a previous snapshot, copy the scratch program over to the virtual machine, and then run it.

Some evidence for those that aren't convinced (I don't blame you): https://i.stack.imgur.com/z3esp.png

Here's the code for the scratch program:

using System;
using System.Globalization;

namespace DuplicateGuid
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0} {1}", Guid.NewGuid(), DateTime.Now.Ticks));

            Console.ReadKey();
        }
    }
}

Could anyone shed some light on how this is possible given that the tick count is different?

9
  • Sounds like a bug for the MS Windows Server team. Apr 20, 2011 at 11:40
  • Is this easily repeatable? Is happening after every time you do a restore and run the program again? For kicks, change the program to output 10 GUIDs and see if all 10 are duplicated. Apr 20, 2011 at 16:32
  • 1
    Yes, this is reproducible. I could go into work tomorrow and probably get the same GUID after restoring the VMWare snapshot. As for repeating multiple GUIDs in quick succession; I'm not too sure. But whether it's 1 or 1,000 reproducable GUIDS, the problem still stands. Apr 20, 2011 at 17:33
  • I'm not sure if I follow your wording here: "I've tried Windows XP and Windows 7 64-bit clients with unsuccessful results." What are you defining as "unsuccessful"? Do you mean that you get duplicate GUIDs on all of those platforms? Or do you mean that the problem is isolated to Server 2008 R2 64-bit? Apr 21, 2011 at 7:25
  • Unsuccessful means not successfully reproducing a GUID. The problem seems to be isolated to a Windows Server 2008 R2 64-bit VMWare guest OS. I think people are starting to miss the point here. I'm able to reproduce a GUID, something I should not be able to do. My question is; does anyone know how or why this is happening, given the scenario I've described? Apr 21, 2011 at 8:54

3 Answers 3

5

Can please you post one of the GUIDs. The image seems to be broken.

See http://en.wikipedia.org/wiki/Globally_unique_identifier specifically "Algorithm". It is likely the platform you are using under Windows 2008 R2 x64 is using version 4 GUIDs. In this case the GUID is generated using pseudo random data. As the CPU is in the same state because you are reverting it back from what I assume is a memory snapshot (correct?) and not a powered off snapshot you are getting duplicate numbers from the pseudo random generator.

It is reasonably common for the operating system to initialise a pseudo random seed once at startup sequentially pulling numbers from the list to make the appearance of a random number. This happens in the Linux world and it is likely that you are observing the same behaviour. Because the sequence of numbers has not been reinitialised and you are reverting back to a memory image you are getting the same numbers.

Using GUID Generator from VS 2010 I got a V4 GUID on Windows 7.

To fix this issue I would first try to apply Windows security fixes which may fix the issue. The problem mostly likely lies in ole32.dll which is called in the Guid.NewGuid method and possibly newer versions reseed the pseudo random number as you didn't get this on newer Windows versions.

Otherwise to work around this issue on the current platform you could:

  1. Generate your own GUID from MAC and time data as specified in OSF specification.

  2. Try to call new Random() prior to your NewGuid call. This probably would be a long shot, but easy to test.

  3. Don't revert from a memory image.

Hope this helps. No doubt you are not the first to have this problem which is why the newer platforms probably reverted to the previous method of using MAC and time data.

0

GUIDs are not guaranteed to be unique, but the probability is extremely small. Maybe you got (un)lucky. :)

2
  • But 3 times (in the example)? And I can continue to reproduce them as well. I can post screenshots of this occurring on previous days, in other virtual machines (with the same guest OS). Basically, the GUID is producible after reverting snapshots. Surely that is NOT possible. Apr 20, 2011 at 11:35
  • Okay, obviously something else is going on here then.
    – Kon
    Apr 20, 2011 at 11:38
0

I wouldn't expect ANY uniqueness from GUIDs generated on a machine without a physical network card. The MAC address of a virtual card is practically guaranteed to repeat on clones of the same VM.

1
  • MAC addresses are not used for v4 GUIDs. .Net makes v4 GUIDs. Sep 12, 2011 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.