Exception Error c0000005 in VC++
Asked Answered
C

2

20

Am working on VC++ Console Application.

This application sends a file from Appdata\Roaming folder for a period of time.

What happens is am getting this Crash error :

Problem signature:
Problem Event Name: APPCRASH
Application Name:   App.exe
Application Version:    1.0.0.2
Application Timestamp:  51c02fa8
Fault Module Name:  PCMeter.exe
Fault Module Version:   1.0.0.2
Fault Module Timestamp: 51c02fa8
Exception Code: c0000005
Exception Offset:   000069eb
OS Version: 6.1.7601.2.1.0.256.48
Locale ID:  1033
Additional Information 1:   0a9e
Additional Information 2:   0a9e372d3b4ad19135b953a78882e789
Additional Information 3:   0a9e
Additional Information 4:   0a9e372d3b4ad19135b953a78882e789

Could anyone please help me to resolve this issue

Cuman answered 18/6, 2013 at 12:33 Comment(3)
c0000005 is the code for an access violation. You'll need to stop referring to memory that is not valid to fix this.Ethelethelbert
Thanks, Am reading the whole xml file using char txt[10000] and passing it to CString value for saving to the server. Does this mean memory violation ?Cuman
if the xml file is larger than 10,000 bytes and you don't limit the number of bytes you copy into the array to 10,000 - then yes, that would cause an access violation.Pyrophoric
E
53

Exception code c0000005 is the code for an access violation. That means that your program is accessing (either reading or writing) a memory address to which it does not have rights. Most commonly this is caused by:

  • Accessing a stale pointer. That is accessing memory that has already been deallocated. Note that such stale pointer accesses do not always result in access violations. Only if the memory manager has returned the memory to the system do you get an access violation.
  • Reading off the end of an array. This is when you have an array of length N and you access elements with index >=N.

To solve the problem you'll need to do some debugging. If you are not in a position to get the fault to occur under your debugger on your development machine you should get a crash dump file and load it into your debugger. This will allow you to see where in the code the problem occurred and hopefully lead you to the solution. You'll need to have the debugging symbols associated with the executable in order to see meaningful stack traces.

Ethelethelbert answered 18/6, 2013 at 12:56 Comment(0)
T
-2

I was having the same problem while running bulk tests for an assignment. Turns out when I relocated some iostream operations (printing to console) from class constructor to a method in class it was solved.

I assume it was something to do with iostream manipulations in the constructor.

Here is the fix:

// Before
CommandPrompt::CommandPrompt() : afs(nullptr), aff(nullptr) {
    cout << "Some text I was printing.." << endl;
};


// After
CommandPrompt::CommandPrompt() : afs(nullptr), aff(nullptr) {

};

Please feel free to explain more what the error is behind the scenes since it goes beyond my cpp knowledge.

Tibbs answered 1/1, 2021 at 7:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.