How the error from 2009 causes a conflict between Docker for Windows and Razer Synapse

Today I came across a very interesting bug: Docker for Windows will not start if you have the Razer Synapse driver control panel running.

But the most interesting thing is why it happened ...



Both applications are written so that you can run only one instance at a time. To do this, they create a global mutex using the .NET assembly as the GUID key, right?

But alas, they are doing it wrong, and moreover, they are equally wrong. The error code looks something like this:

string.Format("Global\{0}", (object) Assembly.GetExecutingAssembly().GetType().GUID);

The idea is to get the GUID of the executable assembly and create a mutex based on it that will prevent more than one instance from starting.

But it must be wrong. There should not be a call GetType().

This option does not return the GUID of a particular assembly, but the GUID of a type built into .NET that describes assemblies as such - System.Reflection.RuntimeAssembly.

Therefore, when they create mutexes, they do not use GUIDs from their own code, but GUIDs from .NET internals. And for both applications, this GUID will be the same.

How did this happen? Funny, but we know exactly how. Stackoverflow is to blame!

Back in 2009, a user with the nickname Nathan asked the question - " how to get the GUID of the assembly being performed?". After 12 minutes, the user Cerebrus answered him, but there was an error in his answer.

After a year and a month, the user Yoopergeek indicates an error. Cerebrus returns three more years later and corrects his answer - but you can’t delete it because the answer has been marked as “accepted.”

Thus, the error in answering the question in 2009 caused a bug that existed at least until March 2018.

Homework for all programmers reading this post: think about how you would find such a bug in your application? the code, it seems to work, but you don’t even realize that it’s actually broken: you don’t run two programs with the same error at the same time, you will only know about the problem when users start complaining.

How could the development process be changed to detect such errors prior to release?

All Articles