Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. crash at vector::push_back.

crash at vector::push_back.

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicshelp
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V VC Maniac

    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

    J Offline
    J Offline
    Jijo Raj
    wrote on last edited by
    #2

    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.

    V 1 Reply Last reply
    0
    • J Jijo Raj

      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.

      V Offline
      V Offline
      VC Maniac
      wrote on last edited by
      #3

      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());
      
      C L S 3 Replies Last reply
      0
      • V VC Maniac

        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());
        
        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #4

        Why are you mixing MFC collections with STL 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]

        V 1 Reply Last reply
        0
        • C CPallini

          Why are you mixing MFC collections with STL 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]

          V Offline
          V Offline
          VC Maniac
          wrote on last edited by
          #5

          Is it a serious issue(mixing MFC with STL)? please explain.

          I C 2 Replies Last reply
          0
          • V VC Maniac

            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());
            
            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            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

            1 Reply Last reply
            0
            • V VC Maniac

              Is it a serious issue(mixing MFC with STL)? please explain.

              I Offline
              I Offline
              Iain Clarke Warrior Programmer
              wrote on last edited by
              #7

              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

              C V 2 Replies Last reply
              0
              • V VC Maniac

                Is it a serious issue(mixing MFC with STL)? please explain.

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #8

                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]

                1 Reply Last reply
                0
                • I Iain Clarke Warrior Programmer

                  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

                  C Offline
                  C Offline
                  CPallini
                  wrote on last edited by
                  #9

                  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]

                  1 Reply Last reply
                  0
                  • I Iain Clarke Warrior Programmer

                    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

                    V Offline
                    V Offline
                    VC Maniac
                    wrote on last edited by
                    #10

                    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!!!

                    1 Reply Last reply
                    0
                    • V VC Maniac

                      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());
                      
                      S Offline
                      S Offline
                      semitae
                      wrote on last edited by
                      #11

                      I had the same problem when porting from VS2005 to VS2008. I avoided it using dynamic allocation something like this: std::vector<???> *v; v = new ???; v->push_back(***) This works in both debug and release mode :)

                      ^^

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups