guy keren wrote:
Christopher Smith wrote:
Tracy R Reed wrote:
I'm with Gus on this one. The number you get when you print a
reference might look like a big number typical of a memory location
but if you reference a different number that you pick at random do
you generally get a segfault?
It isn't necessary that you get a segfault, so long as you get an
error of some kind. Segfaults are just a more painful way of telling
you that you've screwed up (unless you are doing pointer swizzling).
--Chris
the thing that most people find hard to get about such errors, is
their non-deterministic nature. when you screw up your memory -
sometimes you don't see any effect, because you accessed
mapped-yet-unused memory. sometimes you access un-mapped memory (i.e.
memory not mapped in the virtual address space of the process) - and
then you get a seg fault. sometimes you access memory that is maarked
as read-only (when you try to write) or as no-read-no-write (such as
page zero) - and you also get a seg fault. sometimes you access memory
that is used by the program for a different purpose - and then you
don't get any seg fault - because the address is mapped. you screw
something in memory that will only become evident later in the program.
people expect computer programs to be deterministic - but bugs are
non-deterministic, by nature.
Right, which is why you can learn that lesson even in a nice managed
memory environment (particularly if you have threads ;-).
--Chris
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg