The C ++ project I'm working on ends when the first chance exception is thrown. This happens in Visual Studio 2008 in debug mode, when I first try to access a map<pair<int,int>, int> , which contains one key-value pair. There is nothing logical in the code.
I read about the exceptions of the first chance and understand that they may not always be problematic. However, I tried to break all such exceptions, and as expected, several were generated that did not cause a problem.
The class I'm working on is very large and contains many custom memory allocations. I guess for some reason one of them is causing a problem. However, I spent several hours trying to find a way to determine what was going wrong and could not do it.
Below is a list of exception exceptions for the first chance. This is not very helpful!
First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x762cd09c in theapp.exe: 0xC0000005: Access violation reading location 0x6c696d00. First-chance exception at 0x0050ae33 in theapp.exe: 0xC0000005: Access violation reading location 0x00000010. Unhandled exception at 0x0050ae33 in theapp.exe: 0xC0000005: Access violation reading location 0x00000010.
I am really afraid at this moment and do not know how to do it.
Can anyone suggest how I can solve this problem and pinpoint what is happening? I would be very grateful for your advice.
UPDATE
Here is the relevant code. The debugger breaks into the first cout statement specified in the nested FOR:
// Inside operator() : map<pair<int,int>,int> resultIdByStructIds; pair<int,int> spair (-1,-1); // Structure pair ids reusable reference. int nextMapEntryId = 0; int nextNumCandidates = 0; // For each remaining candidate. for (int ci = 0; ci < numCandidates; ) { // If candidate has been mapped or found not viable this mapping round, // move past it. if (candidatesDoneThisRound[ci] == currentMappingRoundId) { ++ci; continue; } Candidate candidate = candidates[ci]; const int tId = candidate.tVertexId; const int pId = candidate.pVertexId; // Grab the result for this structure pair. // Create it if it doesn't exist. // Avoid copying as slight optimisation; simply // store pointer to true result instead. spair.first = tInfos[tId].structure->id; spair.second = pInfos[pId].structure->id; // DEBUG cout << "resultIdByStructIds size: " << resultIdByStructIds.size() << endl; for (map<pair<int,int>,int>::const_iterator ids_id = resultIdByStructIds.begin(); ids_id != resultIdByStructIds.end(); ++ids_id) { cout << ids_id->first.first << endl; // * Debugger breaks here. cout << ids_id->first.second << endl; cout << ids_id->second << endl; printf("Structures(%i,%i) => %i\n",ids_id->first.first,ids_id->first.second,ids_id->second); } // // code continues...
UPDATE 2
Here is a description of the mouse for the map in question; he seems distorted, as Michael Burr suggested.
