views:

105

answers:

2

I had a working MFC application (a dialog application), I deleted some of its button and added a new button, but now when it closes the application crashes. It fails in one of ASSERT() macro. The debug assertions fails on these lines

File: afxtempl.h Line: 558

When I view that code it was something like this

template<class TYPE, class ARG_TYPE>
void CArray<TYPE, ARG_TYPE>::AssertValid() const
{
    CObject::AssertValid();

    if (m_pData == NULL)
    {
     ASSERT(m_nSize == 0);
     ASSERT(m_nMaxSize == 0);
    }
    else
    {
     // here it fails
     ASSERT(m_nSize >= 0);
     ASSERT(m_nMaxSize >= 0);
     ASSERT(m_nSize <= m_nMaxSize);
     ASSERT(AfxIsValidAddress(m_pData, m_nMaxSize * sizeof(TYPE)));
    }
}
#endif //_DEBUG

Any clues as to what is going wrong? The application was working fine when earlier, but I messed it up.

+1  A: 

I'd want to see what is in the stack trace leading up to the assertion - also what is in the various member variables. For example, if the cause is a double deletion, in a debug build you would expect to see the value 0xdddddddd in the value since the debug allocator sets freed memory to this value.

1800 INFORMATION
A: 

I've see crazy things like this when I've inadvertently got duplicate resource ids defined in resource.h. If the only thing you've changed is add/remove a few buttons, I would check this first then try a full rebuild.

Alan
What a fantastic framework ;)
jkp