Live data from Hacker News

What are the odds that some idiot will name his mutex ether-rot-mutex (2017)

etherrotmutex.blogspot.com

1–10 of 176 posts

Re: What are the odds that some idiot will name his mutex ether-rot-mutex (2017)

#7
Back when I was in high school and programming on the original IBM PCs I wrote a program that would graph "solids of rotation" (a function rotated around the X axis). Well I chose the obvious name based on the 8.3 filename limitations. One day someone looked over my shoulder and said "you named your program solid rot???" Oops.

Re: What are the odds that some idiot will name his mutex ether-rot-mutex (2017)

#9

Can someone explain the significance of this like I'm 5?

Mutex is a synchronization primitive implementing mutual exclusion. When created with a name, they can be used to synchronize processes across the whole OS.

For instance, a named mutex is a good way to ensure the program can only be running in a single instance. Specifically, the program creates a named mutex on startup, and locks it forever. If failed to lock, it shows a message saying "another instance is already running" and quit. When the program quits normally, the OS will automatically unlock the mutex, allowing the program to run once again.

Now, imagine that by coincidence, 2 unrelated programs have implemented that approach using the same name for the mutex. This gonna break both of them with weird bugs. Launch program A, then launch program B, and it won't run complaining "another instance is already running" despite that's not true.

For this reason, mutex names are better be very unique.

A typical solution is generating a GUID and using it for the name of the mutex.

But the developer of that particular program instead used the string "What are the odds that some idiot will name his mutex ether-rot-mutex!" They're not wrong in the sense the odds are miniscule, however GUIDs are unique too and much shorter, only 36 characters.

Post reply on HN