I am having a segmentation fault in the erase function of std::vector that is driving me crazy. Am having the following code:
std::map<uint32_t, std::vector<boost::uuids::uuid> >::iterator it
= theAs.find(lSomeUint32);
if (it != theAs.end()) {
std::vector<boost::uuids::uuid>& lIds = it->second; // vector contains one entry
std::vector<boost::uuids::uuid>::iterator it2 = lIds.begin();
while (it2 != lIds.end()) {
if (*it2 == lSomeUuid) {
lIds.erase(it2);
break;
}
++it2;
}
}
In lIds.erase(it2), I get a segmentation fault. More precisely, I get a segmentation fault in _Orphan_range (can be found in c:\Program Files\Microsoft Visual Studio 10.0\VC\include\vector) that is called from erase. But I have no clue why. The vector and the iterator look ok. But in _Orphan_range, something goes completely wrong. The while loop in there is executed three time although my vector contains one item only. In the third run, the variable _Pnext gets broken.
Does someone have an idea? That would be awesome!
David
Unfortunately (or maybe fortunately), the example above executed standalone works. But inside my big software project, it doesn't work.
Does someone know what the failing function _Orphan_range is executed for?