Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#548 HashMap iterator crash in VS 2010

Documentation
closed
7
2012-12-12
2012-07-05
Alex Fabijanic
No

by andycaisc » Thu Mar 08, 2012 3:45 am

typedef HashMap<int, int=""> IntMap;
IntMap hm;
IntMap::Iterator it ;
it = hm.begin(); //---here will make crash in visual studio 2010


by Royce » Thu Jul 05, 2012 9:04 am

I get this same thing. On VS2010, HashMAP::begin() causes a null de-reference deep in the call stack, xutility I think, even if the HashMap has elements. It seems like it is associated with operator= for iterators.

That exact same code on VS2003, on the other hand, works just fine. (I don't have 2005 or 2008 or I would try them too).

Discussion

  • tinyboyz
    tinyboyz
    2012-07-10

    I have the same problem on vs2010.And I try this that also crash on vs2010.

    vector<int> vecInt;
    vector<int>::iterator iterIntVec1;
    vector<int>::iterator iterIntVec2 = vecInt.end();
    swap(iterIntVec1, iterIntVec2);

    The reason is the implementation of struct "_Iterator_base" that is different between vs200x and vs2010 in "xutility" files .

    _Adopt(_Right._Mycont); ====> _Adopt(_Right._Myproxy->_Mycont);

    It caused crash about null reference.

    In a word iterator can not be used without associated with any container.

    We have to do a lot of work to avoid the crash.

     
  • Alex Fabijanic
    Alex Fabijanic
    2012-08-04

    This only happens when assigning to unitialized iterator as specified in the OP. If the iterator is initialized, it wont happen:

    ntMap::Iterator it = hm.begin();

    Guard against this problem has been added in the trunk, rev. 1910:

    http://poco.svn.sourceforge.net/viewvc/poco?view=revision&revision=1910

     
  • Alex Fabijanic
    Alex Fabijanic
    2012-12-12

    • status: open --> closed
    • milestone: --> Documentation
     
  • Alex Fabijanic
    Alex Fabijanic
    2012-12-12

    closing