Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 2nd, 2008, 3:56 PM   #11
dr.p
Programmer
 
dr.p's Avatar
 
Join Date: Feb 2006
Location: Ohio
Posts: 93
Rep Power: 3 dr.p is on a distinguished road
Re: Read Access Violation

Thanks
__________________
Neeley.org
dr.p is offline   Reply With Quote
Old Feb 2nd, 2008, 5:48 PM   #12
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,198
Rep Power: 5 grumpy is on a distinguished road
Re: Read Access Violation

Quote:
Originally Posted by dr.p View Post
Still, why wouldn't it throw an exception when I copied too many bytes from the bitmap file that was already in memory? And why wouldn't it throw an exception when I wrote more data than the memory space could handle?
That's just the way it is in practice.

Laying out a program out in memory so it is possible to detect invalid memory accesses is expensive: results in a program that uses more memory, runs slower, etc, etc. Compiler/linker writers tend to be pressured by developers to produce "efficient" code so they normally do things by assuming code does not do memory overruns. Since the difference, performance wise, can be orders of magnitude, there is a lot of pressure on compiler writers to err on the side of performance at the cost of failing to detect all potential errors.

This means that the layout of variables (or structures or dynamically allocated memory) is not designed to detect overruns. Two unrelated variables A and B may be placed placed adjacent in memory because that happens to be the "optimal" way of laying things out. Code which does an overrun while working with variable A can therefore overwrite variable B, but this will not be detected. If some other code comes along and accesses variable B, it will do something unintended and (probably) write wrong data somewhere else. These things tend to bubble along, until some confused code tromps an area of critical memory -- at which point an invalid access is detected and an error reported (eg exception is thrown).

Products like Electric Fence work by laying out memory and other things so invalid memory accesses are more likely to be detected. In practice, they increase the odds of detecting invalid operations, but do not guarantee they will be detected.
grumpy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
1 line if code blocks; easier to read G.I.Josh Perl 5 Nov 6th, 2007 11:30 PM
read access violation backstabber C++ 14 Oct 13th, 2006 3:54 PM
Access to private files. Jhaqen Java 2 Nov 2nd, 2005 2:35 PM
How to connect with VB to an Access database on another computer iown714 Visual Basic 5 Aug 4th, 2005 10:23 AM
Access Violation Error cornish_boy84 Delphi 1 Mar 1st, 2005 4:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:26 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC