read of address

When running your program, raise an error message, show as following(this message can be copied out by press Ctrl+C key when the error dialog prompt). One thing to make you very depressed was that you have carefully checked your codes many times while nothing found wrong.

---------------------------
Information
---------------------------
Project app.exe faulted with message: 'access violation at 0x40036887: read of address 0x00000010'. Process Stopped. Use Step or Run to continue.
---------------------------
OK  
---------------------------

Do not nervous, Delphi/C++Builder has provide an CodeGuard option. Select project->Options in your develop tools(Delphi or C-Builder), switch to the CodeGurard page, enable the CodeGuard Validate option. Debug your program again, see what happen. Following shows my program's deep error message caught by codeguard.

---------------------------
app.exe
---------------------------
Access violation at address 635F76A5 in module 'mshtml.dll'. Read of address 00000004.
---------------------------
OK  
---------------------------

---------------------------
Debugger Exception Notification
---------------------------
Project app.exe raised exception class EAccessViolation with message 'Access violation at address 40054855 in module 'rtl60.bpl'. Read of address 9BCD9BD5'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help  
---------------------------

This means the error was caused in the inner dll of microsoft's mshtml. Of course to debug the dll file has exceeded my ability. It also tell me that I have used an incorrect way to call the funtion of mshtml. So I improve my codes, and later I solved the problem.

CodeGuard provides runtime debugging for applications developed with C++Builder. It reports errors that are not caught by the compiler because they do not violate syntax rules. CodeGuard tracks Borland runtime libraries, with full support for multithreaded applications.

CodeGuard provides two principal types of coverage:

Memory and resource use. CodeGuard checks for faulty memory use, improper memory allocation or deallocation, invalid file streams or handles, and resource leaks caused by improper use of file streams or handles. It verifies pointers on dereference and checks pointer arithmetic. CodeGuard can report an error if your program tries to access memory or resources that have already been released.
 Function call validation. CodeGuard verifies function arguments and reports function failure as indicated by the function's return value. It validates Windows resource handles used in function calls.

To see a common access violation problems, check out Access violation at address 40A29D24. Read of address 00CB88C4 in C++Builder/Delphi programs

 

Project XXX.exe raised exception class EAccessViolation with message 'Access violation at address 40A29D24. Read of address 00CB88C4'. Process stopped. Use Step or Run to continue. When you debug your codes, you receive such an error prompt.

About an error raise "Access violation at address 40A29D24. Read of address 00CB88C4" in delphi or C++Builder. This is a typical error message raise by the system when you running your program. It means that your program has some problem you have not well handled.

This is always caused by an Illegal access to the memory. Like when you declare an object, but not allocate it in memory, then you access it, the error will raise. Let us take an example:

/*line 1*/        TStringList *pStrList;
/*line 2*/        pStrList->Add("my string one");        //This line will raise an error of "access vialotion at address xxxxxxxx".

The correct codes should be:
/*line 1*/        TStringList *pStrList;
/*line 2*/        pStrList = new TStringList;
/*line 3*/        pStrList->Add("my string one"); 
....................Some Codes Here......................
/*line n*/        delete pStrList;

Sometimes you have check your program many times and found no problems while it still raise such an error, why? I think this mainly caused by the bug of delphi or c++builder's enviroment. You could go the borland's home page to get the latest patch and update your delphi or c++builder.

After you patch your enviroment or there is no patch available while the error still be there. Well, you could check your programs if you have use a TClientDataSet component or you are just programming relative to the database. Try to proper to open the connection and remember to close it before quit the program. This is always effect to avoid the error.

Sometimes you have check your code carefully while still found no error, which can mean an advance error, check out here to use the CodeGuard to debug Project app.exe faulted with message: 'access violation at 0x40036887: read of address 0x00000010'. Process Stopped. Use Step or Run to continue .

And you may get interesting in the following error messages:
Exception class EInvalidCast with message 'Invalid class typecast' in Delphi/C++Builder programs .
Error loading type library/DLL. in delphi programs .
Error loading type library/DLL. in C++Builder Midas App .
project testjpg.exe raised exception class EJPEG with message 'JPEG error # 52' .
Error 823: I/O error on attaching DataBase in Microsoft Sql Server .

Thank you for reading the article, codes here, welcome back!(codeback) And Good Luck!