C’s Revenge

Your C programming tip for today:

When freeing a block of memory, make absolutely sure that there’s nothing else that’s ever going to use it again first.

Especially when that block of memory is being used as part of the processor’s page tables. If you do, your program won’t segfault. It won’t even act strangely in the usual “undefined behavior in C” sense. Oh no. Now the processor’s going to be doing who knows what, since its very notions of what memory looks like have been mangled. There’s no telling what happens after that, but it certainly won’t be anything good.