CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2009
    Posts
    116

    Breakpoint was triggered at dlgcore.cpp

    My application will pop up the warning dialog with description below when running on Windows 7 Japan Version in debug mode using Visual Studio 2010:
    "Windows has triggered a breakpoint in myprogram.exe.
    This may be due to a corruption of the heap, which indicates a bug in myprogram.exe or any of the DLLs it has loaded.
    This may also due to the user pressing F12 while myprogram.exe has focus.
    The output windows may have more diagnostic information."

    However, this error will not happen if I run my application on Windows 7 English Edition. It is running fine.

    When I drill down to have a look, I think the DoModal() function is causing the problem.

    Snippet of my code program:
    Code:
    CMyDIalog dlg;
     dlg.DoModal(); //after executing this, the error happen.
    The breakpoint happen at code below for dlgcore.cpp:
    Code:
    // create modeless dialog
    AfxHookWindowCreate(this);//i think after calling this, the error happen
    hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate,
    	pParentWnd->GetSafeHwnd(), AfxDlgProc);
    This make me wonder why this issue only happen on Windows 7 OS Japan version but not the English version. I did not press F12 while running my program also.
    Any idea how to debug this problem further?

    Attached files Break01.png and Break02.png are the screenshot of my errors.
    Attached Images Attached Images   
    Attached Files Attached Files
    Last edited by PHChang; May 14th, 2016 at 08:54 AM. Reason: Uploaded clearer screenshot in zip file

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Breakpoint was triggered at dlgcore.cpp

    Quote Originally Posted by PHChang View Post
    ...
    This make me wonder why this issue only happen on Windows 7 OS Japan version but not the English version. I did not press F12 while running my program also.
    Any idea how to debug this problem further?

    Attached files ... are the screenshot of my errors.
    Well, your "screenshots" are too small to be understandable.
    What is the return value of CreateDialogIndirect?
    If it is NULL, then what does the GetLastError return?
    Victor Nijegorodov

  3. #3
    Join Date
    Apr 2009
    Posts
    116

    Re: Breakpoint was triggered at dlgcore.cpp

    Sorry for the blur sceenshots, anyway I already attached in the break.zip earlier.

    What is the return value of CreateDialogIndirect?
    I am not too sure what is the value actually because after executing line 2 (I actually set a breakpoint at line 2) the warning dialog "Windows has triggered a breakpoint in myprogram.exe....." prompt out.

    Code:
    // create modeless dialog
    AfxHookWindowCreate(this); //line 1
    hWnd = ::CreateDialogIndirect(hInst, lpDialogTemplate, pParentWnd->GetSafeHwnd(), AfxDlgProc);  //line 2, the warning dialog prompt out after executing this line
    #ifdef _DEBUG
      dwError = ::GetLastError(); //line 3
    After that, I click the "Break" button from the dialog.
    The values became as follow at watch window:
    Name Value
    hWnd 0x001103c8{unused=76}
    dwError 0

    GetLastError return 0 in this case.
    Attached is the screenshot of the values.
    Attached Images Attached Images  

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Breakpoint was triggered at dlgcore.cpp

    What occurs in the dialog's OnInitDialog handler?

  5. #5
    Join Date
    Apr 2009
    Posts
    116

    Re: Breakpoint was triggered at dlgcore.cpp

    What occurs in the dialog's OnInitDialog handler?
    I tried step to the code line by line on my dialog OnInitDialog, it looks fine to me and it didn't trigger the breakpoint.
    Code:
    BOOL CMyDialog::OnInitDialog()
    {
       ........
    }
    //dlgcore.cpp
    Code:
    INT_PTR CALLBACK AfxDlgProc(HWND hWnd, UINT message, WPARAM, LPARAM)
    {
    	if (message == WM_INITDIALOG)
    	{
    		// special case for WM_INITDIALOG
    		CDialog* pDlg = DYNAMIC_DOWNCAST(CDialog, CWnd::FromHandlePermanent(hWnd));
    		if (pDlg != NULL)
    			return pDlg->OnInitDialog();
    		else
    			return 1;
    	}
    	return 0;
    }
    pDlg->OnInitDialog() return value is 0

    The breakpoint only get triggered after executing the CreateDialogIndirect(...) line at dlgcore.cpp
    So I still don't understand why the breakpoint get trigger here.
    Attached Images Attached Images  

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Breakpoint was triggered at dlgcore.cpp

    (a)
    Quote Originally Posted by PHChang View Post
    I tried step to the code line by line on my dialog OnInitDialog, it looks fine to me and it didn't trigger the breakpoint.
    ...
    //dlgcore.cpp
    Code:
    INT_PTR CALLBACK AfxDlgProc(HWND hWnd, UINT message, WPARAM, LPARAM)
    {
    	if (message == WM_INITDIALOG)
    	{
    		// special case for WM_INITDIALOG
    		CDialog* pDlg = DYNAMIC_DOWNCAST(CDialog, CWnd::FromHandlePermanent(hWnd));
    		if (pDlg != NULL)
    			return pDlg->OnInitDialog();
    		else
    			return 1;
    	}
    	return 0;
    }
    (b)
    Quote Originally Posted by PHChang View Post
    ...
    pDlg->OnInitDialog() return value is 0
    Well, (a) contradicts (b). Isn't it?


    Quote Originally Posted by PHChang View Post
    ...
    The breakpoint only get triggered after executing the CreateDialogIndirect(...) line at dlgcore.cpp
    So I still don't understand why the breakpoint get trigger here.
    How did you start the executing: with the debugger (F5) or not?
    Victor Nijegorodov

  7. #7
    Join Date
    Apr 2009
    Posts
    116

    Re: Breakpoint was triggered at dlgcore.cpp

    Well, (a) contradicts (b). Isn't it?
    Sorry, I don't get what you said it contradict each other.

    Because when I saw at the Autos watch window,the value are as follow:
    Name | Value
    CMyDialog::OnInitDialog return | 0

    So if my understanding is correct pDlg->OnInitDialog() return value is 0 based on the watch window. Do correct me if I am wrong.
    I have attached the screenshot in zip file. (My image always get resize after uploaded and become blur so I zip the image inside instead)

    How did you start the executing: with the debugger (F5) or not?
    Yes, I started the executing by pressing F5 debugger.
    When I say "The breakpoint only get triggered" , I actually meant the warning dialog "The breakpoint only get triggered" prompt out.
    Attached Files Attached Files

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,398

    Re: Breakpoint was triggered at dlgcore.cpp

    Quote Originally Posted by PHChang View Post
    So if my understanding is correct pDlg->OnInitDialog() return value is 0 based on the watch window. Do correct me if I am wrong.
    I have attached the screenshot in zip file. (My image always get resize after uploaded and become blur so I zip the image inside instead)


    Yes, I started the executing by pressing F5 debugger.
    When I say "The breakpoint only get triggered" , I actually meant the warning dialog "The breakpoint only get triggered" prompt out.
    But, being on the line
    Code:
                return pDlg->OnInitDialog();
    did you try to press F11 to step in the code of CMyDialog::OnInitDialog (or CDialog::OnInitDialog)?
    Victor Nijegorodov

  9. #9
    Join Date
    Apr 2009
    Posts
    116

    Re: Breakpoint was triggered at dlgcore.cpp

    did you try to press F11 to step in the code of CMyDialog::OnInitDialog (or CDialog::OnInitDialog)?
    Yes, I did step through the code but it did not trigger the warning dialog "Breakpoint was trigger".
    Code:
    BOOL CMyDialog::OnInitDialog()
    {
       CDialog::OnInitDialog();  //already step through this line and no warning dialog prompt out
       //my code
     ........
      //my code end
      return FALSE;
    }
    I am still cannot find the abnormalities that cause this.

  10. #10
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Breakpoint was triggered at dlgcore.cpp

    The heap may be corrupted, this is what the message box tells you. So you'd better start looking in your code for wild pointers, stack corruption, buffer overruns and other nice things like that. Try to disable some code fragments and see if that helps your dialog box to show up.
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured