Windows allows you to detect these kinds of things using structured exception handling.
tj963
Memory leak depate. Linux vs windows vs another?
accessing memory that is not yours happens in a buffer overflow. and possibly in funky pointer arithmetic.
A memory leak occurs when you allocate memory and do not free it, as demonstrated by Libvan's buggy code.
A "memory read overrun" or "memory write overrun" occurs when you read/write memory outside of the program structure's intent. (This is what you've been talking about.) The OS kernel should only check to the granuality of the page-size (typically 4k) if it has an MMU. Without an MMI it will not perform any checking at all (most embedded devices do not have an MMU).
Under Windows using C you should be able use SEH (structured exception handling) to catch this exception (these exceptions are translated to the int type for C++ exception handling. e.g. catch(int err){} ). I'm not certain if/how the exception is delivered under Linux, probably a signal for both C & C++.
There's a tool called BoundsChecker which is part of DevPartner made by CompuWare for MSVC that will dynamically (at run-time) detect memory overruns in your code (among other many other problems such as leaks).
A "memory read overrun" or "memory write overrun" occurs when you read/write memory outside of the program structure's intent. (This is what you've been talking about.) The OS kernel should only check to the granuality of the page-size (typically 4k) if it has an MMU. Without an MMI it will not perform any checking at all (most embedded devices do not have an MMU).
Under Windows using C you should be able use SEH (structured exception handling) to catch this exception (these exceptions are translated to the int type for C++ exception handling. e.g. catch(int err){} ). I'm not certain if/how the exception is delivered under Linux, probably a signal for both C & C++.
There's a tool called BoundsChecker which is part of DevPartner made by CompuWare for MSVC that will dynamically (at run-time) detect memory overruns in your code (among other many other problems such as leaks).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement