Sorry, that's a ridiculous assertion. Catching segfaults is a useful
software technique that can be used to do cool things. A software emulator for
a CPU can catch a segfault to detect that writes are taking place to simulated
I/O space. Garbage collectors can use segfaults. Some Lisp implementations
catch SIGSEGV as part of their garbage collector implementation. For instance
CLISP has a "libsigsegv" library for handling access violations and fixing them
up:
http://libsigsegv.sourceforge.net/
That's an implementation detail, strongly cooperating with system
level. It has
completely nothing to do with SEGV occuring in C++ programs.
That is a silly view. Detecting the error already provides security and
integrity.
SEGV is not "detecting the error". SEGV is detecting the situation
that shouldn't
have occurred - it means that, of course, reporting SEGV means error,
but this
can quickly lead us to a statement that "not reporting SEGV means no
error in
data integrity", which is not true anyway - SEGV might have been only
one of
possible realizations of "undefined behavior". Others are e.g. writing
to a
memory not expected to be written.
What I mean is that SEGV doesn't just mean that "well, some error
happened".
It means that the runtime code went totally out of control and caused
much
more damage in the runtime data than just one stupid SEGV.
Note that virtual machines with strict memory assignment have much
more
possibilities to catch this kind of error. In Java, for example, you
are
not allowed to cast pointers, so writing to the other object than you
wanted
ends up with an exception (although you still can write to an
incorrect cell
in the array, or to an incorrect object in the list).
In all advanced CPU architectures, exceptions store enough information sothat
the handler can recover by fixing the situation and resuming the program (if
that makes sense).
Terminating the program isn't the only possibility.
When the code ran out of control, terminating the program is the only
sensible
way to continue. Terminating the program may even save the user's data
from
being lost (think what would happen if a corrupted program would next
write
the data to a file, overwriting previous data).
Since architectures provide the capability, it means that higher level
languages which do not map the capability are crippled with respect to machine
language.
I.e. you have some better exception handling features at the instruction set
level than you do in C++.
SEGV should be treated strictly as "the code run out of control". So
the only
situation when you'd like to handle this error is when you are running
a code
contained in a kind-of plugin or explicitly separated part of code,
where you
know that you didn't let this code operate with any global data - in
other words,
you know that whatever happened in the code, it happened in its
private pool.
In this case you can catch the SEGV exception and immediately kill the
plugin
or part (part can be, for example, a TAB in a web browser), then
continue with
the rest of the applicaiton.
In any other case you should let your program crash because it's the
best you
can do to stop any further damage.
Please find more detailed information in the following article:
http://sektorvanskijlen.wordpress.com/2011/01/05/exceptions-konsidered-harmfool/
Regards,
Sektor