Using Self-Modifying Code


What is it:

Trying to change your code while it is executing.

Why it's bad:

Code may become read-only.

What to do

Don't do it.

Many programming tricks depend on being able to change portions of your code while it is executing. Don't assume that you can write to your code. If your code resides in protected memory, trying to modify it will cause an abort, which in turn causes your task to abort. In addition, code can't modify itself in future systems with a CPU cache.