I'm using a class which holds a private list:
class Set
{
private:
list<long long unsigned> ways; //holds tags of addresses
and as part of the class's functionality I'm managing a LIFO on the list 'ways':
list<long long unsigned>::iterator it = ways.begin();
while (it!= ways.end()) //looks for the tag in the list
{
if ((*it) == tag) //tag is found in this set. moves the tag to the end of the list
{
ways.erase(it);
ways.push_back(tag);
return true;
}
it++;
}
return false;
and:
if (occupied < maxWays) //if the set is not all used up just pushes tag in the end
{
ways.push_back(tag);
occupied++;
return false;
}
else // if used up pops the front member (the least recently used one)
{
ways.pop_front();
ways.push_back(tag);
}
return true;
Nothing else touches 'ways' and nothing else erases the class 'set'. Multiple instances of the class 'set' are created at the beginning.
During operation I'm getting Segmentation Fault for
list<long long unsigned>::iterator it = ways.begin();
which occurs after a long run. Trying to print the address of 'ways' before this line shows that at the point that I'm about to get Segmentation Fault the address of 'ways' changed dramatically. All the previous times it was around 0x6000xxxxx for each instance, and at that time it was 0x23.
I don't have a clue what can cause that, please assist.