NT 4.0 allows memory access violations!!! 
Author Message
 NT 4.0 allows memory access violations!!!

The following piece of code runs without error on Windows 4.0 (service
pack 2) and is terminated with a dialog message under 3.51 (service pack
4).

The program calls CopyRect with an uninitilized pointer, which attempts
to read from memory location 0.  I realize that NT 4.0 moved code to
ring zero to enhance performance.  How much did they move?  Will NT 4.0
allow writes to location 0 as well?  Is NT no longer a memory access
protected Operating System?

#include <afxwin.h>
int main ()
{
    RECT    dstRect;
    LPRECT  srcRect;

    srcRect = 0;

    CopyRect (&dstRect, srcRect);

    return 1;

Quote:
}

----------------------------------------------------------------------
Frank C. Garber               Voice: 860.627.1629 - current assignment
Software Devel. Consultant    Fax:   860.627.1666

Burlington, CT  06013-2220    WWW:   http://www.*-*-*.com/ ~garberfc

    >>Only by attempting the absurd do we achieve the impossible<<

----------------------------------------------------------------------



Tue, 03 Aug 1999 03:00:00 GMT  
 NT 4.0 allows memory access violations!!!

Felix,
A couple points to note:
CopyRect arguments go like this: CopyRect (destination, source)
  - all you printfs were stated backwards.

I know all about return codes... It' very difficult to check them when
your application is terminated (NT 3.51) with a "Application Error".
The instruction at "0x?????" referenced memory at "0x0000000". The
memory could not be "read".

So I'll re-ask the original question.  Does NT4.0 check and report
memory access violations?  CopyRect() was just an example.  CopyRect()
was part of an argument to a constructor where it was not possible to
check a return code.  And yes I know about exception handling...

The reason this problem was discovered at all is because we have some
developers coding in 4.0 and others with 3.51.  The code ran without a
hitch under 4.0 and dies a sudden death under 3.51.

        Thanks,  Frank



Fri, 06 Aug 1999 03:00:00 GMT  
 NT 4.0 allows memory access violations!!!

Frank,

 > So I'll re-ask the original question.  Does NT4.0 check and report
 > memory access violations?  CopyRect() was just an example.

Yes, access violations are checked and reported. CopyRect() was not a
good example because it validates its arguments before trying
anything; that's why I included direct access through a pointer.

If an app works on 4.0 and dies a sudden death under 3.51, my first
suspicion would be that is uses NT4-only functionality or something
like that.

Cheers,
Felix.

----------
If you post a reply, kindly refrain from emailing it, too.



Sat, 07 Aug 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. NT 4.0 unchecked memory access violation!!!

2. Shared Memory, NT 4.0, object memory allocation (new)

3. Access Violation (NTDLL.DLL): 0xC0000005 only in Debug Mode on NT and Win2k

4. Virtual Memory paging when an app minimizes in NT 4.0

5. fwrite on NT 4.0 Server causing memory depletion

6. Virtual Memory paging when an app minimizes in NT 4.0

7. Windows NT 4.0 and memory management

8. ATL dll problem 0xC0000005 access violation or memory could not be read

9. memory access violation

10. memory access violations

11. Memory Access Violation in Release mode only

12. Memory Access Violation in Release Mode-Solution Found

 

 
Powered by phpBB® Forum Software