On Sun, Oct 16, 2011 at 11:54 PM, Gor Gyolchanyan <
[email protected]> wrote:

> If the user tries to read unallocated memory, the memory can't
> possibly get corrupted, since nothing is getting changed.
> If the user tried to write to unallocated memory, the segfault should
> _prevent_ it by throwing an OS-level exception (the sigsegv). Throwing
> if _after_ the invalid write makes no sense. You can't save anything,
> because your own data is not touched. Depending on the implementation,
> either some other process's memory would be touched or nothing at all
> (internally unmapped region).
> I think the rumors of corrupted memory after sigsegv is boloney.
> Otherwise the whole sigsegv idea is pointless (you could just as well
> get terminated right away).


The problem is that there's no guarantee that you *only* wrote outside your
allocated virtual memory. You could have a bad pointer, overwrite half your
program's data, then hit an invalid address and segfault. There are many
scenarios in which bad writes *don't* cause segfaults (they may be
incorrect, but they're still legal), so you can't really assume much about
your program's state when you segfault.

Reply via email to