Dear All,
I am working on a project which is a mixture of dialog and MDI. The project started as a tabbed dialog project. Later MDI was added to it. On clicking one of the tabs the MDI is invoked. Without clicking the a particular tab it remains only a dialog based project.
The project works fine in release build. When I do a debug build I get a crash when I click on the tab that initializes the MDI main frame and window. Given below is the piece of code that is executed for MID window creation.
The crash message is
Unhandled exception at 0x590C0983 (msvcr120d.dll) in MarkBullV3.exe: 0xC000041D: An unhandled exception was encountered during a user callback.
Any help would be very much appreciated. Feel free to ask any question you may have.
Thanks & Regards,
Rakesh
pDocTemplate = new CMultiDocTemplate(IDR_Test1TYPE,
RUNTIME_CLASS(CTest1Doc),
RUNTIME_CLASS(CChildFrame), //custom MDI child frame
RUNTIME_CLASS(CTest1View));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);
LOGD.LOGRP(FL, "After pDocTemplate creation");
pMainFrame = new CMainFrame;
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME1))
{
LOGD.LOGRP(FL, "main Frame not created");
delete pMainFrame;
return FALSE;
}
m_pMainWnd = pMainFrame;
for (i = 0; i < 16; i++)
theApp.OnFileNew();
LOGD.LOGRP(FL, "Check0");
//pMainFrame->MDITile();
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
pMainFrame->ShowWindow(m_nCmdShow);
LOGD.LOGRP(FL, "Before UpdateWindow");
pMainFrame->UpdateWindow();
LOGD.LOGRP(FL, "After UpdateWindow");
totCustomPlotCount = 0;
LOGD.LOGRP(FL, "End of window creation in initinstance11");
I find the crash happens on UpdateWindow. So I commented that and I find that the crash still happens.
Given below is the stack on crash
msvcr120d.dll!_CrtDbgBreak() Line 87 C
msvcr120d.dll!_VCrtDbgReportA(int nRptType, void * returnAddress, const char * szFile, int nLine, const char * szModule, const char * szFormat, char * arglist) Line 290 C
msvcr120d.dll!_CrtDbgReportV(int nRptType, void * returnAddress, const char * szFile, int nLine, const char * szModule, const char * szFormat, char * arglist) Line 262 C
msvcr120d.dll!_CrtDbgReport(int nRptType, const char * szFile, int nLine, const char * szModule, const char * szFormat, ...) Line 279 C
> mfc120d.dll!AfxAssertFailedLine(const char * lpszFileName, int nLine) Line 24 C++
mfc120d.dll!CScrollView::OnPrepareDC(CDC * pDC, CPrintInfo * pInfo) Line 387 C++
mfc120d.dll!CView::OnPaint() Line 185 C++
mfc120d.dll!CWnd::OnWndMsg(unsigned int message, unsigned int wParam, long lParam, long * pResult) Line 2448 C++
mfc120d.dll!CWnd::WindowProc(unsigned int message, unsigned int wParam, long lParam) Line 2094 C++
mfc120d.dll!AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 282 C++
mfc120d.dll!AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 435 C++
mfc120d.dll!AfxWndProcBase(HWND__ * hWnd, unsigned int nMsg, unsigned int wParam, long lParam) Line 299 C++
user32.dll!744084f3() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]
[External Code]
V3.exe!V10App::InitInstance() Line 291 C++
[External Code]
V3.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 26 C++
[External Code]
The last function called is below
_CRTIMP int __cdecl _VCrtDbgReportA
(
int nRptType,
void * returnAddress,
const char * szFile,
int nLine,
const char * szModule,
const char * szFormat,
va_list arglist
)
{
int retval=0;
int handled=FALSE;
char szLineMessage[DBGRPT_MAX_MSG] = {0};
char szOutMessage[DBGRPT_MAX_MSG] = {0};
wchar_t szOutMessage2[DBGRPT_MAX_MSG] = {0};
char szUserMessage[DBGRPT_MAX_MSG] = {0};
if (nRptType < 0 || nRptType >= _CRT_ERRCNT)
return -1;
__try
{
if (_CRT_ASSERT == nRptType && InterlockedIncrement(&_crtAssertBusy) > 0)
{
_ERRCHECK(_itoa_s(nLine, szLineMessage, DBGRPT_MAX_MSG, 10));
OutputDebugStringA("Second Chance Assertion Failed: File ");
OutputDebugStringA(szFile ? szFile : "<file unknown>");
OutputDebugStringA(", Line ");
OutputDebugStringA(szLineMessage);
OutputDebugStringA("\n");
_CrtDbgBreak();
retval=-1;
}
else
{
if (szFormat)
{
int szlen = 0;
_ERRCHECK_SPRINTF(szlen = _vsnprintf_s(szUserMessage, DBGRPT_MAX_MSG,
DBGRPT_MAX_MSG - 2- max(sizeof(ASSERTINTRO1),sizeof(ASSERTINTRO2)),
szFormat, arglist));
if (szlen < 0)
{
_ERRCHECK(strcpy_s(szUserMessage, DBGRPT_MAX_MSG, DBGRPT_TOOLONGMSG));
}
}
if (_CRT_ASSERT == nRptType)
_ERRCHECK(strcpy_s(szLineMessage, DBGRPT_MAX_MSG, szFormat ? ASSERTINTRO1 : ASSERTINTRO2));
_ERRCHECK(strcat_s(szLineMessage, DBGRPT_MAX_MSG, szUserMessage));
if (_CRT_ASSERT == nRptType)
{
if (_CrtDbgMode[nRptType] & _CRTDBG_MODE_FILE)
_ERRCHECK(strcat_s(szLineMessage, DBGRPT_MAX_MSG, "\r"));
_ERRCHECK(strcat_s(szLineMessage, DBGRPT_MAX_MSG, "\n"));
}
if (szFile)
{
int szlen = 0;
_ERRCHECK_SPRINTF(szlen = _snprintf_s(szOutMessage, DBGRPT_MAX_MSG, DBGRPT_MAX_MSG - 1, "%s(%d) : %s",
szFile, nLine, szLineMessage));
if (szlen < 0)
{
_ERRCHECK(strcpy_s(szOutMessage, DBGRPT_MAX_MSG, DBGRPT_TOOLONGMSG));
}
}
else
_ERRCHECK(strcpy_s(szOutMessage, DBGRPT_MAX_MSG, szLineMessage));
{
size_t ret = 0;
errno_t e = 0;
_ERRCHECK_EINVAL_ERANGE(e = mbstowcs_s(&ret, szOutMessage2, DBGRPT_MAX_MSG, szOutMessage, _TRUNCATE));
if(e != 0)
_ERRCHECK(wcscpy_s(szOutMessage2, DBGRPT_MAX_MSG, _CRT_WIDE(DBGRPT_INVALIDMSG)));
}
if (_pReportHookList || _pReportHookListW)
{
ReportHookNode *pnode=NULL;
ReportHookNodeW *pnodeW=NULL;
_mlock(_DEBUG_LOCK);
__try
{
for (pnode = _pReportHookList; pnode; pnode = pnode->next)
{
int hook_retval=0;
if ((*pnode->pfnHookFunc)(nRptType, szOutMessage, &hook_retval))
{
handled=TRUE;
retval=hook_retval;
break;
}
}
if(!handled)
{
for (pnodeW = _pReportHookListW; pnodeW; pnodeW = pnodeW->next)
{
int hook_retval=0;
if ((*pnodeW->pfnHookFunc)(nRptType, szOutMessage2, &hook_retval))
{
handled=TRUE;
retval=hook_retval;
break;
}
}
}
}
__finally
{
_munlock(_DEBUG_LOCK);
}
}
if(!handled)
{
if(_pfnReportHook)
{
int hook_retval=0;
if(((*_pfnReportHook)(nRptType, szOutMessage, &hook_retval)))
{
handled=TRUE;
retval=hook_retval;
}
}
if (!handled)
{
if (_CrtDbgMode[nRptType] & _CRTDBG_MODE_FILE)
{
if (_CrtDbgFile[nRptType] != _CRTDBG_INVALID_HFILE)
{
DWORD written;
WriteFile(_CrtDbgFile[nRptType], szOutMessage, (unsigned long)strlen(szOutMessage), &written, NULL);
}
}
if (_CrtDbgMode[nRptType] & _CRTDBG_MODE_DEBUG)
{
OutputDebugStringA(szOutMessage);
}
if (_CrtDbgMode[nRptType] & _CRTDBG_MODE_WNDW)
{
szLineMessage[0] = 0;
if (nLine)
{
_ERRCHECK(_itoa_s(nLine, szLineMessage, DBGRPT_MAX_MSG, 10));
}
retval = __crtMessageWindowA(nRptType, returnAddress, szFile, (nLine ? szLineMessage : NULL), szModule, szUserMessage);
}
}
}
}
}
__finally
{
if (_CRT_ASSERT == nRptType)
{
InterlockedDecrement(&_crtAssertBusy);
}
}
return retval;
}
> mfc120d.dll!CScrollView::OnPrepareDC(CDC * pDC, CPrintInfo * pInfo) Line 387 C++
void CScrollView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
ASSERT_VALID(pDC);
if (m_bInitialRedraw)
{
return;
}
#ifdef _DEBUG
if (m_nMapMode == MM_NONE)
{
TRACE(traceAppMsg, 0, "Error: must call SetScrollSizes() or SetScaleToFitSize()");
TRACE(traceAppMsg, 0, "\tbefore painting scroll view.\n");
ASSERT(FALSE); return;
}
#endif //_DEBUG
ASSERT(m_totalDev.cx >= 0 && m_totalDev.cy >= 0);
switch (m_nMapMode)
{
case MM_SCALETOFIT:
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowExt(m_totalLog);
pDC->SetViewportExt(m_totalDev);
if (m_totalDev.cx == 0 || m_totalDev.cy == 0)
TRACE(traceAppMsg, 0, "Warning: CScrollView scaled to nothing.\n");
break;
default:
ASSERT(m_nMapMode > 0);
pDC->SetMapMode(m_nMapMode);
break;
}
CPoint ptVpOrg(0, 0);
if (!pDC->IsPrinting())
{
ASSERT(pDC->GetWindowOrg() == CPoint(0,0));
ptVpOrg = -GetDeviceScrollPosition();
if (m_bCenter)
{
CRect rect;
GetClientRect(&rect);
if (m_totalDev.cx < rect.Width())
ptVpOrg.x = (rect.Width() - m_totalDev.cx) / 2;
if (m_totalDev.cy < rect.Height())
ptVpOrg.y = (rect.Height() - m_totalDev.cy) / 2;
}
}
pDC->SetViewportOrg(ptVpOrg);
CView::OnPrepareDC(pDC, pInfo);
}
/////////////////////////////////////////////////////////////////////////
OnPaint function and the runtime parameters are
void CView::OnPaint()
{
// standard paint routine
CPaintDC dc(this);
OnPrepareDC(&dc);
OnDraw(&dc);
}
- dc {hWnd=0x002003d4 {unused=??? }} CPaintDC
- CDC {hDC=0x30011223 {unused=??? } attrib=0x30011223 {unused=??? }} CDC
+ CObject {...} CObject
+ m_hDC 0x30011223 {unused=??? } HDC__ *
+ m_hAttribDC 0x30011223 {unused=??? } HDC__ *
m_bPrinting 0 int
+ m_hWnd 0x002003d4 {unused=??? } HWND__ *
- m_ps {hdc=0x30011223 {unused=??? } fErase=0 rcPaint={top=0 bottom=247 left=0 right=424} ...} tagPAINTSTRUCT
+ hdc 0x30011223 {unused=??? } HDC__ *
fErase 0 int
+ rcPaint {top=0 bottom=247 left=0 right=424} tagRECT
fRestore 0 int
fIncUpdate 0 int
+ rgbReserved 0x0017851c "" unsigned char[32]
- this 0x0b19a708 {hWnd=0x002003d4 {unused=??? }} CView *
- [CTest1View] {hWnd=0x002003d4 {unused=??? }} MarkBullV3.exe!CTest1View
+ CScrollView {hWnd=0x002003d4 {unused=??? }} MarkBullV3.exe!CScrollView
Is_Graph_Data_3D 0 int
Graph_Type 4 int
WinIndentifier 4 int
WinIdentifierCnst -842150451 int
+ pData2 0x0b19a7c4 {{x=-431602080. y=-431602080. z=-431602080. }, {x=-431602080. y=-431602080. z=-431602080. }, ...} MarkBullV3.exe!t_FLOATPOINT[2000]
+ pData3 0x0b1a0584 {{x=-431602080. y=-431602080. z=-431602080. }, {x=-431602080. y=-431602080. z=-431602080. }, ...} MarkBullV3.exe!t_FLOATPOINT[2000]
+ pData1 0x0b1a6344 {{x=-431602080. y=-431602080. z=-431602080. }, {x=-431602080. y=-431602080. z=-431602080. }, ...} MarkBullV3.exe!t_FLOATPOINT[2000]
ColR 0 unsigned long
ColG 0 unsigned long
ColB 0 unsigned long
FirstEntry 0 int
+ m_LinePlot {hWnd=0x00000000 <null>} MarkBullV3.exe!CLinePlot
+ m_cmbStyle {hWnd=0x00000000 <null>} MarkBullV3.exe!CComboBox
+ m_lstReceived {hWnd=0x00000000 <null>} MarkBullV3.exe!CListBox
cnumValuesPkOrderSqncBkSwing -842150451 int
+ PkAngPosSqncBkSwing 0x0b1acc24 {-842150451, -842150451, -842150451, -842150451, -842150451, -842150451, -842150451, -842150451, ...} int[10]
+ PkOrderSqncBkSwing 0x0b1acc4c {-842150451, -842150451, -842150451, -842150451, -842150451, -842150451, -842150451, -842150451, ...} int[10]
OnLButtonDownId 0 unsigned int
rotUp 0 int
rotDown 0 int
rotLeft 0 int
rotRight 0 int
zoomHdClub 0 int
unzoomHdClub 0 int
genTestVariable 0 int
+ CWnd {hWnd=0x002003d4 {unused=??? }} CWnd
+ m_pDocument 0x081dfc10 {...} CDocument *
m_bInitialRedraw 0 int
What I have tried:
I have tried to comment UpdateWindow. I have tried to see the stack and find possible pointers that may have gone wrong, but not much clarity came out of it.
Regards,
Rakesh