Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to debug an application and I keep running into this error around the break point:

SQL
File f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\filelist.cpp
Line:255


What does this error mean? The following is my call stack around the point where a debug assertion error occurs:

VB
mfc100d.dll!CRecentFileList::Add(const char * lpszPathName, const char * lpszAppID)  Line 225 + 0x25 bytes  C++
mfc100d.dll!CWinApp::AddToRecentFileList(const char * lpszPathName)  Line 84    C++
mfc100d.dll!CDocument::SetPathName(const char * lpszPathName, int bAddToMRU)  Line 296  C++
mfc100d.dll!COleDocument::SetPathName(const char * lpszPathName, int bAddToMRU)  Line 183   C++
WinSTM.exe!CWinSTMDoc::CopyDoc(CWinSTMDoc * pDocNew, int chan)  Line 486 + 0x3b bytes   C++
WinSTM.exe!CWinSTMView::CreateNewDoc(CWinSTMDoc * pDoc)  Line 2717  C++
WinSTM.exe!CWinSTMView::OnImageAutoPlane()  Line 4789 + 0x11 bytes  C++
mfc100d.dll!_AfxDispatchCmdMsg(CCmdTarget * pTarget, unsigned int nID, int nCode, void (void)* pfn, void * pExtra, unsigned int nSig, AFX_CMDHANDLERINFO * pHandlerInfo)  Line 82   C++
mfc100d.dll!CCmdTarget::OnCmdMsg(unsigned int nID, int nCode, void * pExtra, AFX_CMDHANDLERINFO * pHandlerInfo)  Line 381 + 0x27 bytes  C++
mfc100d.dll!CView::OnCmdMsg(unsigned int nID, int nCode, void * pExtra, AFX_CMDHANDLERINFO * pHandlerInfo)  Line 166 + 0x18 bytes   C++
mfc100d.dll!CFrameWnd::OnCmdMsg(unsigned int nID, int nCode, void * pExtra, AFX_CMDHANDLERINFO * pHandlerInfo)  Line 969 + 0x23 bytes   C++
mfc100d.dll!CWnd::OnCommand(unsigned int wParam, long lParam)  Line 2676    C++
mfc100d.dll!CFrameWnd::OnCommand(unsigned int wParam, long lParam)  Line 371    C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult)  Line 2081 + 0x1e bytes  C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam)  Line 2067 + 0x20 bytes    C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam)  Line 248 + 0x1c bytes  C++
mfc100d.dll!CMDIFrameWnd::OnCommand(unsigned int wParam, long lParam)  Line 48 + 0x23 bytes C++
mfc100d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult)  Line 2081 + 0x1e bytes  C++
mfc100d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam)  Line 2067 + 0x20 bytes    C++
mfc100d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam)  Line 248 + 0x1c bytes  C++
mfc100d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam)  Line 411    C++
mfc100d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam)  Line 420 + 0x15 bytes   C++
user32.dll!_InternalCallWinProc@20()  + 0x23 bytes
user32.dll!_UserCallWinProcCheckWow@32()  + 0xb3 bytes
user32.dll!_DispatchMessageWorker@8()  + 0xe6 bytes
user32.dll!_DispatchMessageA@4()  + 0xf bytes
mfc100d.dll!AfxInternalPumpMessage()  Line 183  C++
mfc100d.dll!CWinThread::PumpMessage()  Line 900 C++
mfc100d.dll!CWinThread::Run()  Line 629 + 0xd bytes C++
mfc100d.dll!CWinApp::Run()  Line 822    C++
mfc100d.dll!AfxWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow)  Line 47 + 0xd bytes   C++
WinSTM.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow)  Line 26   C++
WinSTM.exe!__tmainCRTStartup()  Line 547 + 0x2c bytes   C
WinSTM.exe!WinMainCRTStartup()  Line 371    C
kernel32.dll!@BaseThreadInitThunk@12()  + 0x12 bytes
ntdll.dll!___RtlUserThreadStart@8()  + 0x27 bytes
ntdll.dll!__RtlUserThreadStart@8()  + 0x1b bytes


Here are my autos/variable values:

-&psi    0x0024eb78 {0x00000000}  ATL::CComPtr<IShellItem> *
-ATL::CComPtrBase<IShellItem>    {p=0x00000000 } ATL::CComPtrBase<IShellItem>
-       p   0x00000000  IShellItem *
-       IUnknown    {...}   IUnknown
        __vfptr CXX0030: Error: expression cannot be evaluated


Here is the code where the assertion occurs:
void CDocument::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU)
{
	// store the path fully qualified
	TCHAR szFullPath[_MAX_PATH];
	ENSURE(lpszPathName);
	if ( lstrlen(lpszPathName) >= _MAX_PATH )
	{
		ASSERT(FALSE);
		// MFC requires paths with length < _MAX_PATH
		// No other way to handle the error from a void function
		AfxThrowFileException(CFileException::badPath);
	}
	if( AfxFullPath(szFullPath, lpszPathName) == FALSE )
	{
		ASSERT(FALSE);
		// MFC requires paths with length < _MAX_PATH
		// No other way to handle the error from a void function
		AfxThrowFileException(CFileException::badPath);
	}
	m_strPathName = szFullPath;
	ASSERT(!m_strPathName.IsEmpty());       // must be set to something
	m_bEmbedded = FALSE;
	ASSERT_VALID(this);
	// set the document title based on path name
	TCHAR szTitle[_MAX_FNAME];
	if (AfxGetFileTitle(szFullPath, szTitle, _MAX_FNAME) == 0)
		SetTitle(szTitle);
	// add it to the file MRU list
	if (bAddToMRU)
		AfxGetApp()->AddToRecentFileList(m_strPathName);
	ASSERT_VALID(this);
}


Is this just telling me that a pointer is bad?

Thanks!
Posted
Updated 1-Aug-11 9:51am
v2
Comments
Albert Holguin 26-Jul-11 20:40pm    
You didn't post what the error or assertion is. Post the error or assertion message, otherwise, there's no way to know what's wrong.
AndrewG1231 27-Jul-11 14:19pm    
All the message says is, "Debug Assertion Failed! Program: C:...path to the .exe, File:f:\dd\vctools.....line:225" following the message, I press retry to debug and it causes a break at the mfc100d.dll call.
Pradeep Shukla 29-Jul-11 11:21am    
Can you post the code where you are hitting this issue..that could help to find it...
AndrewG1231 1-Aug-11 15:51pm    
Done, took my a bit, but the code where the assertion occurs is posted.
Mic72 26-Jan-12 13:43pm    
I have the same problem in the same source code: calling the CDocument::SetPathName the system fires an exception

if ( lstrlen(lpszPathName) >= _MAX_PATH )
{
ASSERT(FALSE);
// MFC requires paths with length < _MAX_PATH
// No other way to handle the error from a void function
AfxThrowFileException(CFileException::badPath);
}

but the size of lpszPathName is less than _MAX_PATH.
Have you solved your problem?

So,after a lot of guidance from the c++/mfc forum, the answers to the questions here, and Ivor Horton's book on Visual Studio 2010 I was able to solve the error.

The error first was being thrown by the return value of E_INVALIDARG for the variable hr in
ENSURE(SUCCEEDED(hr))
After stepping back we found a stale memory value for
ShellCreateItemFromParsingName()
Making some break points and continuing to step back the problem code was narrowed the function where we were copying the document:
CString OldPath = GetPathName();
pDocNew->SetPathName(OldPath + " *");
	
CString OldTitle = GetTitle();
pDocNew->SetTitle(OldTitle + " *");
It seems that Visual Studio 2010 did not like the " *" being added to the file name or path. Once it was removed from both places problem was resolved. Now the program is fully functional. Thanks for all the help with the debugging techniques, they are valuable skills!
 
Share this answer
 
I had a customer with the same problem. For an unknown reason, a function higher in the stack decided that the file passed to CRecentFileList::Add() did not exist. This is strange because the file was either just opened or just saved to.

My solution was to overload CWinAppEx::AddToRecentFileList() in order to catch and ignore any exceptions. You can be extra safe and check the exception type if you want.

I like this solution because you shouldn't have to change your code if Microsoft changes the base class implementation in the future. And because it works for both saving and loading.

C#
void CMyApp::AddToRecentFileList(LPCTSTR lpszPathName)
{
    try
    {
        // Call the base class
        CWinAppEx::AddToRecentFileList(lpszPathName);
    }
    catch (CException * e)
    {
        CString strCause;
        e->GetErrorMessage(strCause.GetBuffer(800), 800);
        strCause.ReleaseBuffer();
        TRACE("Exception in %s: %s.  -- Ignoring\n", __FUNCTION__, strCause);
        e->Delete();
    }
}


Enjoy.
 
Share this answer
 
I had this problem too, because the file path included \..\ in itself.

All I had to do was a PathCanonicalize before to remove these kinds of things.
 
Share this answer
 
I have the same problem in the same source code: calling the CDocument::SetPathName the system fires an exception

if ( lstrlen(lpszPathName) >= _MAX_PATH )
{
ASSERT(FALSE);
// MFC requires paths with length < _MAX_PATH
// No other way to handle the error from a void function
AfxThrowFileException(CFileException::badPath);
}

but the size of lpszPathName is less than _MAX_PATH.
Have you solved your problem?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900