A self-testing application?

I know some embedded engineers write code that checks memory content at runtime to ensure the code being executed is actually what is supposed to be executed. Something to do unstable hardware. And of course fixing that after detecting mismatch.