seg fault from std::list.push_back()
Hello,
I'm a C++ newbie and having a hard time figuring out this bug.
I am basically doing the following thing:
Code:
std::vector< std::list<int> > x;
x = std::vector< std::list<int> > (n);
for (int i = 0; i < n; i++)
for (int r = 0; r < m[i]; r++)
x[i].push_back(r);
The initialization of vector was done alright.
Then, I sometimes see segmentation fault in the middle of the double "for" loops, i.e. from push_back.
Does this mean the node allocator of list is touching some corrupted memory, and therefore a memory leak somewhere else?
btw, I have tried to catch the memory bug using valgrind and totalview from Etnus but they didn't find anything. Can you recommend any tips or useful tools for this?
- EJ