0
votes

Im trying to run my .exe but the application is crashing

Upon debugging I get the following break in the vector class. It breaks at this->Orphan_all.

Unhandled exception at 0x0562DF58 (msvcp120d.dll) in ExploringSfMExec.exe: 0xC0000005: Access violation reading location 0xCDCDCDD1.

void clear() _NOEXCEPT
    {   // erase all
    this->_Orphan_all();
    _Destroy(this->_Myfirst, this->_Mylast);
    this->_Mylast = this->_Myfirst;
    }

Any ideas?

Thanks

1
Compile all your application with all warnings & debug info (e.g. g++ -Wall -Wextra -g if using GCC...) Then use the debugger (e.g. gdb) and look into the call stack (e.g. with backtrace) Perhaps the reciever (i.e. this) is null? - Basile Starynkevitch
This is the error. I am using windows visual studio 2010. Unhandled exception at 0x0562DF58 (msvcp120d.dll) in ExploringSfMExec.exe: 0xC0000005: Access violation reading location 0xCDCDCDD1. - West1234
We cannot debug your application with only 5 lines of code (the bug is likely elsewhere, perhaps in the caller function). You need to learn how to do debugging. - Basile Starynkevitch

1 Answers

1
votes

Somewhere along the road, you have created an illegal std::vector pointer.

The following minimal program will reproduce the problem:

#include <vector>

int main()
{
    std::vector<int>* v;
    v->clear(); // will cause access violation in MSVC
}

v->clear() yields undefined behaviour, and MSVC turns this undefined behaviour into what you are experiencing.

That's really all we can tell you with the error description you have given to us. Since you are already using a debugger anyway, trace back the call to clear until you find the illegal pointer.