Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFC Application Crashes while closing

Tags:

assert

crash

mfc

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.

like image 352
akif Avatar asked May 19 '26 23:05

akif


1 Answers

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.

like image 145
1800 INFORMATION Avatar answered May 22 '26 01:05

1800 INFORMATION



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!