Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Double free exception with Vector

Thread Tools

Double free exception with Vector
Posts: n/a
I am having some difficulty with the STL vector class throwing a double
free exception. The problem is that I don't use pointers anywhere in
my program. The double free currently occurs when I call push_back().
The stack trace shows that the double free stems from the following
lines in vector.tcc (from gcc):

- this->_M_impl._M_start);

This line is in the function:

template<typename _Tp, typename _Alloc>
vector<_Tp, _Alloc>&
vector<_Tp, _Alloc>::
operator=(const vector<_Tp, _Alloc>& __x);

This happens when I try and use push_back() on a private variable from
within the class. If I try it on a local variable everything operates
as expected. I tried to trace the problem down to see what exactly the
variable "_M_impl" is, but I couldn't find it. Also, the coding
convention used is a bit unintuitive and I couldn't figure out from the
code what exactly the purpose of this line was. I suppose it is
deallocating something from start to end, and my problem is that this
has been deallocated as some time in the past already. I would post my
code, but it's part of a larger application and not very simple. I
tried to contrive an example, but I couldn't reproduce the problem.
Any ideas?

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Free memory allocate by a STL vector, vector of vector, map of vector C++ 8 02-18-2006 12:48 AM
Double free exception with Vector C++ 2 09-15-2005 05:54 PM
Double free exception with Vector C++ 0 09-14-2005 12:08 AM
performance of std::vector<double>, double[] and uBlas::vector ondifferent CPU Ingo Nolden C++ 15 04-30-2005 03:31 PM
cannot convert parameter from 'double (double)' to 'double (__cdecl *)(double)' error Sydex C++ 12 02-17-2005 06:30 PM