On x86, if you set the AM flag in the CR0 register and set the AC flag in the EFLAGS register, any unaccepted memory access on CPL 3 (user user level) will throw a #AC exception (interrupt 17). Since these bits are usually clear, and access to them is privileged, you will need to make some effort to enable them (which may not be possible on some operating systems).
source
share