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
.



Relevant Pages

  • Re: Is There Any Reason to Even Use VC++ Anymore?
    ... If, for another reason, the calling function needs to allocate memory, ... It does this by taking a pointer to a ball object ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Pointer to the out of scope local variables
    ... of a pointer, and jumped to the conclusion that you allocated the memory ... In this particular case the funtion buildPoint would allocate ... If the caller ...
    (microsoft.public.vc.language)
  • Re: Memory management and allocation
    ... > As I'm writing a piece of code that basically acts as a server and ... > memory management is a topic that is quite crucial. ... Or can I just allocate the variable ... Nor is it usually necessary to set the pointer to ...
    (comp.lang.c)
  • Re: Virtual Machine implementation problem, Please help me to spot the bug
    ... I kept on getting error messages. ... You don't allocate enough memory here. ... Again conversions between pointer and integer types. ...
    (comp.lang.c)
  • Re: This is getting really weird.
    ... I thought 4 bytes for reference count and 4 for string length. ... > There should be no memory allocation for that line. ... > manager may allocate more space than requested for its own efficiency. ... > that New returned with a pointer to the string constant. ...
    (alt.comp.lang.borland-delphi)