Quantcast
Channel: Why is a segmentation fault not recoverable? - Stack Overflow
Viewing all articles
Browse latest Browse all 17

Why is a segmentation fault not recoverable?

$
0
0

Following a previous question of mine, most comments say "just don't, you are in a limbo state, you have to kill everything and start over". There is also a "safeish" workaround.

What I fail to understand is why a segmentation fault is inherently nonrecoverable.

The moment in which writing to protected memory is caught - otherwise, the SIGSEGV would not be sent.

If the moment of writing to protected memory can be caught, I don't see why - in theory - it can't be reverted, at some low level, and have the SIGSEGV converted to a standard software exception.

Please explain why after a segmentation fault the program is in an undetermined state, as very obviously, the fault is thrown before memory was actually changed (I am probably wrong and don't see why). Had it been thrown after, one could create a program that changes protected memory, one byte at a time, getting segmentation faults, and eventually reprogramming the kernel - a security risk that is not present, as we can see the world still stands.

  1. When exactly does a segmentation fault happen (= when is SIGSEGV sent)?
  2. Why is the process in an undefined behavior state after that point?
  3. Why is it not recoverable?
  4. Why does this solution avoid that unrecoverable state? Does it even?

Viewing all articles
Browse latest Browse all 17

Latest Images

Trending Articles





Latest Images