tags:

views:

50

answers:

1

I have an application which is trying to populate a pair. Out of nowhere the application crashes.

The Windbg analysis on the crash dump suggests:

PRIMARY_PROBLEM_CLASS: INVALID_POINTER_READ

DEFAULT_BUCKET_ID: INVALID_POINTER_READ

STACK_TEXT:
0389f1dc EPFilter32!std::vector<std::pair<unsigned int,unsigned int>,std::allocator<std::pair<unsigned int,unsigned int> > >::size+0xc

INVALID_POINTER_READ_c0000005_Test.DLL!std::vector_std::pair_unsigned_int, unsigned_int_,std::allocator_std::pair_unsigned_int,unsigned_int_____::size

Following is the code snap in the code where it fails:

for (unsigned i1 = 0;  i1 < size1;  ++i1)
{
    for (unsigned i2 = 0;  i2 < size2;  ++i2)
    {
      const branch_info& b1 =  en1.m_branches[i1];   //Exception here :crash 
      const branch_info& b2 =  en2.m_branches[i2];
    }
}

where branch_info is std::pair<unsigned int,unsigned int> and the en1.m_branches[i1] fetches me a pair value.

+3  A: 

Probably the i1 index is out of the bounds of the en1.m_branches vector.

Why don't you use en1.m_branches.size() in your loop condition? This would make sure you use indexes inside the correct bounds.

sth
yeah but thats not consistent
sameer karjatkar
@sameer not consistent with what?
pmr