Why are we all worked up about atomicity when applying hot-patches if we can just suspend all the threads?
cppdashboard.dev/r/2026/11/why-are-we-all-worked-up-about-atomicity-when-applying-hot-pThis article discusses the importance of atomicity in the Windows hot-patching system and the potential issues that arise when suspending threads during patching. It highlights the risks of executing half-installed patches and the challenges posed by new threads being created during the process.
From the article
I noted that one of the concerns of the Windows hot-patching system is that the patch can be activated atomically. But why does it need to be atomic? Can’t just suspend all the threads of the process (except for the one doing the patching)? That way, nobody else can be executing a half-installed patch.
For processors with variable-length instructions ( looking at you, x86 ), the patched instruction cannot be shorter than its replacement. This applies even if you can suspend all the threads of the process, because you might suspend a thread just as it’s about to execute bytes from what would be the second of half of the replacement instruction.
If you were unlucky and froze the thread after it executed the XX instruction and was about to execute the YY instruction, and then replaced both…
Share this resource