It means something has overwritten one of the chunks of data that malloc keeps in between the allocated chunks for keeping track of how big the chunks are and which are free.
Usually it means your program has written slightly beyond the end of some memory allocation and the error occurs when you try to free that allocation.
Originally Posted by mayankladoia
vector< vector<double> > arr;
Assuming that is the object directly involved in the problem, you probably assign a value to an out of range element of arr. Ho do you use arr? Do you do anything equivalent to
arr[i][j] = something
If so, then I expect at some point j was greater than the value of x-1 as of the prior resize.
If the first subscript had been too large, it would point to something that isn't a vector and most likely seg fault right there. But if the second subscript were too large, it would just overwrite memory it doesn't own and most likely fail on a subsequent free() exactly as you're seeing.
But the assumption that arr is directly involved is just an assumption. You have a "memory clobber" bug and those are tricky. You seem to have found that a difference in the way you set the size of arr causes the bug to occur or not occur. That may make you conclude that arr is directly involved. But in many memory clobber bugs any change in any part of the program might hide the bug (make it symptom free). So look at arr first, because it is easier to check and has a decent chance to be the direct cause. But you might need some advanced gdb technique to find the real bug if it is actually somewhere else in your code.