crash at vector::push_back.
-
I have a vector that contains POSITIONs. When I try to push_back or clear, the program crashes. The callstack shows _invalid_parameter_noinfo in one of the frames. I googled and found a solution(defining _HAS_ITERA.... and _SECURE_SCL to 0) , but was not effective. I'm using VS2008 with MFC feature pack installed on vista. Please help. Thanks
-
Can be due to a lot of reasons. Could you please provide relevant code snippet and call stack during crash? Regards, Jijo.
_____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
The call stack: > Desktop.exe!_crt_debugger_hook(int _Reserved=0) Line 65 C Desktop.exe!_invalid_parameter(const wchar_t * pszExpression=0x00000000, const wchar_t * pszFunction=0x00000000, const wchar_t * pszFile=0x00000000, unsigned int nLine=0, unsigned int pReserved=0) Line 112 + 0x7 bytes C++ Desktop.exe!_invalid_parameter_noinfo() Line 125 + 0xc bytes C++ Desktop.exe!std::vector >::insert(std::_Vector_const_iterator > _Where=..., CRecord * const & _Val=0x01703200) Line 878 + 0x1e bytes C++ Desktop.exe!COutlineTextView::prepareSelBounds() Line 4816 C++ Desktop.exe!COutlineTextView::OnMouseMove(unsigned int nFlags=1, CPoint point={...}) Line 167 + 0x40 bytes C++ Desktop.exe!COutlineEditView::OnMouseMove(unsigned int nFlags=1, CPoint pointMove={...}) Line 2935 C++ Desktop.exe!CWnd::OnWndMsg(unsigned int message=512, unsigned int wParam=1, long lParam=3231936, long * pResult=0x007bfc9c) Line 2062 C++ Code snippet where it crashes:
declared as
std::vector<POSITION> m_selection;in member function:
if (m_selection.size() > 0){
m_selection.clear(); // previously used to crash here.
} // then I put this if.........
,.............
.......
POSITION pos = m_selStart.getItem();
while(pos != NULL && pos != m_selEnd.getItem())
{
m_selection.push_back(pos); // CRASH HERE
pos = getMan()->getNext(pos);
}ASSERT(pos); m\_selection.push\_back(m\_selEnd.getItem());
-
The call stack: > Desktop.exe!_crt_debugger_hook(int _Reserved=0) Line 65 C Desktop.exe!_invalid_parameter(const wchar_t * pszExpression=0x00000000, const wchar_t * pszFunction=0x00000000, const wchar_t * pszFile=0x00000000, unsigned int nLine=0, unsigned int pReserved=0) Line 112 + 0x7 bytes C++ Desktop.exe!_invalid_parameter_noinfo() Line 125 + 0xc bytes C++ Desktop.exe!std::vector >::insert(std::_Vector_const_iterator > _Where=..., CRecord * const & _Val=0x01703200) Line 878 + 0x1e bytes C++ Desktop.exe!COutlineTextView::prepareSelBounds() Line 4816 C++ Desktop.exe!COutlineTextView::OnMouseMove(unsigned int nFlags=1, CPoint point={...}) Line 167 + 0x40 bytes C++ Desktop.exe!COutlineEditView::OnMouseMove(unsigned int nFlags=1, CPoint pointMove={...}) Line 2935 C++ Desktop.exe!CWnd::OnWndMsg(unsigned int message=512, unsigned int wParam=1, long lParam=3231936, long * pResult=0x007bfc9c) Line 2062 C++ Code snippet where it crashes:
declared as
std::vector<POSITION> m_selection;in member function:
if (m_selection.size() > 0){
m_selection.clear(); // previously used to crash here.
} // then I put this if.........
,.............
.......
POSITION pos = m_selStart.getItem();
while(pos != NULL && pos != m_selEnd.getItem())
{
m_selection.push_back(pos); // CRASH HERE
pos = getMan()->getNext(pos);
}ASSERT(pos); m\_selection.push\_back(m\_selEnd.getItem());
Why are you mixing
MFC
collections withSTL
ones?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Why are you mixing
MFC
collections withSTL
ones?If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
The call stack: > Desktop.exe!_crt_debugger_hook(int _Reserved=0) Line 65 C Desktop.exe!_invalid_parameter(const wchar_t * pszExpression=0x00000000, const wchar_t * pszFunction=0x00000000, const wchar_t * pszFile=0x00000000, unsigned int nLine=0, unsigned int pReserved=0) Line 112 + 0x7 bytes C++ Desktop.exe!_invalid_parameter_noinfo() Line 125 + 0xc bytes C++ Desktop.exe!std::vector >::insert(std::_Vector_const_iterator > _Where=..., CRecord * const & _Val=0x01703200) Line 878 + 0x1e bytes C++ Desktop.exe!COutlineTextView::prepareSelBounds() Line 4816 C++ Desktop.exe!COutlineTextView::OnMouseMove(unsigned int nFlags=1, CPoint point={...}) Line 167 + 0x40 bytes C++ Desktop.exe!COutlineEditView::OnMouseMove(unsigned int nFlags=1, CPoint pointMove={...}) Line 2935 C++ Desktop.exe!CWnd::OnWndMsg(unsigned int message=512, unsigned int wParam=1, long lParam=3231936, long * pResult=0x007bfc9c) Line 2062 C++ Code snippet where it crashes:
declared as
std::vector<POSITION> m_selection;in member function:
if (m_selection.size() > 0){
m_selection.clear(); // previously used to crash here.
} // then I put this if.........
,.............
.......
POSITION pos = m_selStart.getItem();
while(pos != NULL && pos != m_selEnd.getItem())
{
m_selection.push_back(pos); // CRASH HERE
pos = getMan()->getNext(pos);
}ASSERT(pos); m\_selection.push\_back(m\_selEnd.getItem());
ThisIsMeRon wrote:
Desktop.exe!_invalid_parameter_noinfo() Line 125 + 0xc bytes C++
Looks like a CRT invalid argument error. You can use _set_invalid_parameter_handler[^] to set a custom handler for whatever invalid argument is being passed. Note that not correctly handling the error could mask the real problem. Best Wishes, -David Delaune
-
It's not FATAL - but the two mindsets of the framework designers are quite different. So you're setting yourself up for confusion. Which is never good. I find it confusing enough just getting out of bed. Iain.
modified on Friday, December 19, 2008 10:07 AM
-
Nope, if you're able to master both. Anyway, if you're able to master both then you don't mix them. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
It's not FATAL - but the two mindsets of the framework designers are quite different. So you're setting yourself up for confusion. Which is never good. I find it confusing enough just getting out of bed. Iain.
modified on Friday, December 19, 2008 10:07 AM
Iain Clarke wrote:
It's not FATAL - but the two mindsets of the framework designers are quite different.
Also the quality of the two mindsets is quite different (as usual this is going on my arrogant...) :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
It's not FATAL - but the two mindsets of the framework designers are quite different. So you're setting yourself up for confusion. Which is never good. I find it confusing enough just getting out of bed. Iain.
modified on Friday, December 19, 2008 10:07 AM
The problem is still not solved. I have some classes that inherit from vectors. I have a vector of POSITION(in afx.h)
// abstract iteration position
struct __POSITION {};
typedef __POSITION* POSITION;So when I try to push a POSITION value to the vector I get this crash saying invalid parameter. In call stack I see its trying to push(insert) a value of different type (ref. classes that inherit from vectors) other than POSITION. How is this possible? Please help!!!
-
The call stack: > Desktop.exe!_crt_debugger_hook(int _Reserved=0) Line 65 C Desktop.exe!_invalid_parameter(const wchar_t * pszExpression=0x00000000, const wchar_t * pszFunction=0x00000000, const wchar_t * pszFile=0x00000000, unsigned int nLine=0, unsigned int pReserved=0) Line 112 + 0x7 bytes C++ Desktop.exe!_invalid_parameter_noinfo() Line 125 + 0xc bytes C++ Desktop.exe!std::vector >::insert(std::_Vector_const_iterator > _Where=..., CRecord * const & _Val=0x01703200) Line 878 + 0x1e bytes C++ Desktop.exe!COutlineTextView::prepareSelBounds() Line 4816 C++ Desktop.exe!COutlineTextView::OnMouseMove(unsigned int nFlags=1, CPoint point={...}) Line 167 + 0x40 bytes C++ Desktop.exe!COutlineEditView::OnMouseMove(unsigned int nFlags=1, CPoint pointMove={...}) Line 2935 C++ Desktop.exe!CWnd::OnWndMsg(unsigned int message=512, unsigned int wParam=1, long lParam=3231936, long * pResult=0x007bfc9c) Line 2062 C++ Code snippet where it crashes:
declared as
std::vector<POSITION> m_selection;in member function:
if (m_selection.size() > 0){
m_selection.clear(); // previously used to crash here.
} // then I put this if.........
,.............
.......
POSITION pos = m_selStart.getItem();
while(pos != NULL && pos != m_selEnd.getItem())
{
m_selection.push_back(pos); // CRASH HERE
pos = getMan()->getNext(pos);
}ASSERT(pos); m\_selection.push\_back(m\_selEnd.getItem());