Re: Reading from invalid memory



"soccertl" <lambert54@xxxxxxx> writes:

Thanks for all the replies.

I am not trying to get anyone riled up. What I was trying to do was
get something similar to the OS I came from. I was not trying to
create a function that access memory in invalid ways. I was just
creating that condition to see if it was possible to detect an
invliad pointer.

I previously programmed in OS/2, which has memory checking APIs that
allow you to check if a pointer is valid. If you have a pointer that
is 0, points to memory you did not allocate, points to memory you
allocated but is no longer allocated, or points to memory you have
allocated but the size you expect it to be is not within the allowed
access range, it detects all these conditions and fails the memory
check.

There are a number of memory debugging tools available in unixland,
both open source and commercial. Most people use those since you can't
rely on an implementation of C to do it for you.

Google for "memory debugging tools" to get a set of options you can
look at.

If this has already been suggested, sorry. I've been away for a while.

Joe
--
Gort, klatu barada nikto
.