Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem with heap/OK button error

Problem with heap/OK button error

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++debuggingtutorialquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Grahamfff
    wrote on last edited by
    #1

    Get the following run time error after making a few changes in my MFC application. Not been able to find where it occurs other than when I click on the OK button of the Main Dialog.

    This may be due to a corruption of the heap, which indicates a bug in MFCTest.exe or any of the DLLs it has loaded.

    This may also be due to the user pressing F12 while MFCTest.exe has focus.

    The output window may have more diagnostic information.
    HEAP[MFCTest.exe]: Invalid Address specified to RtlValidateHeap( 003C0000, 003C8E70 )
    Windows has triggered a breakpoint in MFCTest.exe.

    This may be due to a corruption of the heap, which indicates a bug in MFCTest.exe or any of the DLLs it has loaded.

    This may also be due to the user pressing F12 while MFCTest.exe has focus.

    The output window may have more diagnostic information.
    Object dump complete.

    Any suggestions to how to locate this heap problem? I think I deleted the OK button and then tryied to undo the changes.

    grahamfff

    D S 2 Replies Last reply
    0
    • G Grahamfff

      Get the following run time error after making a few changes in my MFC application. Not been able to find where it occurs other than when I click on the OK button of the Main Dialog.

      This may be due to a corruption of the heap, which indicates a bug in MFCTest.exe or any of the DLLs it has loaded.

      This may also be due to the user pressing F12 while MFCTest.exe has focus.

      The output window may have more diagnostic information.
      HEAP[MFCTest.exe]: Invalid Address specified to RtlValidateHeap( 003C0000, 003C8E70 )
      Windows has triggered a breakpoint in MFCTest.exe.

      This may be due to a corruption of the heap, which indicates a bug in MFCTest.exe or any of the DLLs it has loaded.

      This may also be due to the user pressing F12 while MFCTest.exe has focus.

      The output window may have more diagnostic information.
      Object dump complete.

      Any suggestions to how to locate this heap problem? I think I deleted the OK button and then tryied to undo the changes.

      grahamfff

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2
      • Do you have a handler for the OK button? If so, what's in it?

      • Does the problem happen when you click the Cancel button?

      • You mentioned "Main Dialog." Are other dialogs involved?

      • Does this happen with a basic application, or only after you add other code to it?

      • Are you linking with other libraries?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

      G 1 Reply Last reply
      0
      • D David Crow
        • Do you have a handler for the OK button? If so, what's in it?

        • Does the problem happen when you click the Cancel button?

        • You mentioned "Main Dialog." Are other dialogs involved?

        • Does this happen with a basic application, or only after you add other code to it?

        • Are you linking with other libraries?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

        G Offline
        G Offline
        Grahamfff
        wrote on last edited by
        #3

        It happens after all the code in the OnBnClose() has run. I deleted the Cancel button a long time ago. The are other modal dialogs but they are OK. I think I got confused when I deleted the OnOK() routine and tried to reinstate it. It is using IDOK as a resourse. Its a big MFC application and I deleted some controls and control variables but seemed to have got in a mess. I can usually sort things out, but this time because its at the program termination phase I am a bit lost as nothing to bebug.

        grahamfff

        A 1 Reply Last reply
        0
        • G Grahamfff

          It happens after all the code in the OnBnClose() has run. I deleted the Cancel button a long time ago. The are other modal dialogs but they are OK. I think I got confused when I deleted the OnOK() routine and tried to reinstate it. It is using IDOK as a resourse. Its a big MFC application and I deleted some controls and control variables but seemed to have got in a mess. I can usually sort things out, but this time because its at the program termination phase I am a bit lost as nothing to bebug.

          grahamfff

          A Offline
          A Offline
          Alan Balkany
          wrote on last edited by
          #4

          It's possible the memory corruption is happening way before your OnOK handler is being called; it's just being detected there. Calling this: http://msdn.microsoft.com/en-us/library/y1132dee%28v=vs.80%29.aspx[^] at various times will help to localize where this is happening. Another approach is the Binary Chop Debugging Pattern: Comment out portions of your program and rerun. If the problem remains, the bug isn't in the removed code. This debugging pattern can sometimes localize the bug orders of magnitude faster than trying to find it logically. Visual Studio 6 had a way to invoke afxCheckMemory () after each operation, which is slow but will find the memory bug when it happens. I haven't seen this facility on later VS versions, though.

          1 Reply Last reply
          0
          • G Grahamfff

            Get the following run time error after making a few changes in my MFC application. Not been able to find where it occurs other than when I click on the OK button of the Main Dialog.

            This may be due to a corruption of the heap, which indicates a bug in MFCTest.exe or any of the DLLs it has loaded.

            This may also be due to the user pressing F12 while MFCTest.exe has focus.

            The output window may have more diagnostic information.
            HEAP[MFCTest.exe]: Invalid Address specified to RtlValidateHeap( 003C0000, 003C8E70 )
            Windows has triggered a breakpoint in MFCTest.exe.

            This may be due to a corruption of the heap, which indicates a bug in MFCTest.exe or any of the DLLs it has loaded.

            This may also be due to the user pressing F12 while MFCTest.exe has focus.

            The output window may have more diagnostic information.
            Object dump complete.

            Any suggestions to how to locate this heap problem? I think I deleted the OK button and then tryied to undo the changes.

            grahamfff

            S Offline
            S Offline
            Stephen Hewitt
            wrote on last edited by
            #5

            Try enabling the "page heap" for the process. Remember to turn it off when you're done debugging.

            Steve

            G 1 Reply Last reply
            0
            • S Stephen Hewitt

              Try enabling the "page heap" for the process. Remember to turn it off when you're done debugging.

              Steve

              G Offline
              G Offline
              Grahamfff
              wrote on last edited by
              #6

              Not done the heap page (as dont know how) But with the AfxCheckMemory() I get the following, puting the statement in InitDlg() routine. Again do not understand.

              ntdll.dll!7c90120e()
              [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
              ntdll.dll!7c96ee31()
              ntdll.dll!7c95f8f4()
              ntdll.dll!7c96e94d()
              ntdll.dll!7c96f586()
              ntdll.dll!7c962fcf()
              user32.dll!7e418bd9()
              user32.dll!7e41885a()
              user32.dll!7e42a013()
              user32.dll!7e43e577()
              user32.dll!7e42a998()
              user32.dll!7e43e577()

              mfc90d.dll!CWnd::DefWindowProcA(unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 1043 + 0x20 bytes C++
              mfc90d.dll!CWnd::Default() Line 274 C++
              mfc90d.dll!CDialog::HandleInitDialog(unsigned int __formal=723394, unsigned int __formal=723394) Line 673 + 0x8 bytes C++
              mfc90d.dll!CWnd::OnWndMsg(unsigned int message=272, unsigned int wParam=723394, long lParam=0, long * pResult=0x0013e2dc) Line 2018 + 0x11 bytes C++
              mfc90d.dll!CWnd::WindowProc(unsigned int message=272, unsigned int wParam=723394, long lParam=0) Line 1755 + 0x20 bytes C++
              mfc90d.dll!AfxCallWndProc(CWnd * pWnd=0x0013e7b4, HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 240 + 0x1c bytes C++
              mfc90d.dll!AfxWndProc(HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 403 C++
              mfc90d.dll!AfxWndProcBase(HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 441 + 0x15 bytes C++
              user32.dll!7e418734()
              user32.dll!7e418816()
              user32.dll!7e42927b()
              user32.dll!7e42651a()
              user32.dll!7e42683e()
              user32.dll!7e439b43()
              mfc90d.dll!CWnd::CreateDlgIndirect(const DLGTEMPLATE * lpDialogTemplate=0x00480aa0, CWnd * pParentWnd=0x00000000, HINSTANCE__ * hInst=0x00400000) Line 312 + 0x2a bytes C++
              mfc90d.dll!CDialog::DoModal() Line 576 + 0x20 bytes C++
              MFCTest.exe!CMFCTestApp::InitInstance() Line 63 + 0xb bytes C++
              mfc90d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00161f0a, int nCmdShow=1) Line 37 + 0xd bytes C++
              MFCTest.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00161f0a, int nCmdShow=1) Line 30 C++
              MFCTest.exe!__tmainCRTStartup() Line 574 + 0x35 bytes C
              MFCTest.exe!WinMainCRTStart

              S G 2 Replies Last reply
              0
              • G Grahamfff

                Not done the heap page (as dont know how) But with the AfxCheckMemory() I get the following, puting the statement in InitDlg() routine. Again do not understand.

                ntdll.dll!7c90120e()
                [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
                ntdll.dll!7c96ee31()
                ntdll.dll!7c95f8f4()
                ntdll.dll!7c96e94d()
                ntdll.dll!7c96f586()
                ntdll.dll!7c962fcf()
                user32.dll!7e418bd9()
                user32.dll!7e41885a()
                user32.dll!7e42a013()
                user32.dll!7e43e577()
                user32.dll!7e42a998()
                user32.dll!7e43e577()

                mfc90d.dll!CWnd::DefWindowProcA(unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 1043 + 0x20 bytes C++
                mfc90d.dll!CWnd::Default() Line 274 C++
                mfc90d.dll!CDialog::HandleInitDialog(unsigned int __formal=723394, unsigned int __formal=723394) Line 673 + 0x8 bytes C++
                mfc90d.dll!CWnd::OnWndMsg(unsigned int message=272, unsigned int wParam=723394, long lParam=0, long * pResult=0x0013e2dc) Line 2018 + 0x11 bytes C++
                mfc90d.dll!CWnd::WindowProc(unsigned int message=272, unsigned int wParam=723394, long lParam=0) Line 1755 + 0x20 bytes C++
                mfc90d.dll!AfxCallWndProc(CWnd * pWnd=0x0013e7b4, HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 240 + 0x1c bytes C++
                mfc90d.dll!AfxWndProc(HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 403 C++
                mfc90d.dll!AfxWndProcBase(HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 441 + 0x15 bytes C++
                user32.dll!7e418734()
                user32.dll!7e418816()
                user32.dll!7e42927b()
                user32.dll!7e42651a()
                user32.dll!7e42683e()
                user32.dll!7e439b43()
                mfc90d.dll!CWnd::CreateDlgIndirect(const DLGTEMPLATE * lpDialogTemplate=0x00480aa0, CWnd * pParentWnd=0x00000000, HINSTANCE__ * hInst=0x00400000) Line 312 + 0x2a bytes C++
                mfc90d.dll!CDialog::DoModal() Line 576 + 0x20 bytes C++
                MFCTest.exe!CMFCTestApp::InitInstance() Line 63 + 0xb bytes C++
                mfc90d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00161f0a, int nCmdShow=1) Line 37 + 0xd bytes C++
                MFCTest.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00161f0a, int nCmdShow=1) Line 30 C++
                MFCTest.exe!__tmainCRTStartup() Line 574 + 0x35 bytes C
                MFCTest.exe!WinMainCRTStart

                S Offline
                S Offline
                Stephen Hewitt
                wrote on last edited by
                #7

                The problem has already occurred before your app explodes. The page heap will tell you more, but it probably happens in CMFCTestApp::InitInstance (or something called from there) but before the call to DoModal. B

                Steve

                G 1 Reply Last reply
                0
                • S Stephen Hewitt

                  The problem has already occurred before your app explodes. The page heap will tell you more, but it probably happens in CMFCTestApp::InitInstance (or something called from there) but before the call to DoModal. B

                  Steve

                  G Offline
                  G Offline
                  Grahamfff
                  wrote on last edited by
                  #8

                  Thanks for all who posted. But as I cannot get a handle on the problem which may be due to using an existing MFC application for a simular one. I deleteled some controls and renamed some of the dialogus and classes (including files names) and seem to have done something that has resulted in the basic framework failing. Perhaps the Close button problem was a 'red herring' and perhaps best to start again and copy over code snipps as could spend ages on this problem and get nowhere. I always found it difficult to reuse an MFC application. I have checked butons, textboxes dropdown lists etc and the resourses and event handlers but still the problem remains.

                  grahamfff

                  1 Reply Last reply
                  0
                  • G Grahamfff

                    Not done the heap page (as dont know how) But with the AfxCheckMemory() I get the following, puting the statement in InitDlg() routine. Again do not understand.

                    ntdll.dll!7c90120e()
                    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
                    ntdll.dll!7c96ee31()
                    ntdll.dll!7c95f8f4()
                    ntdll.dll!7c96e94d()
                    ntdll.dll!7c96f586()
                    ntdll.dll!7c962fcf()
                    user32.dll!7e418bd9()
                    user32.dll!7e41885a()
                    user32.dll!7e42a013()
                    user32.dll!7e43e577()
                    user32.dll!7e42a998()
                    user32.dll!7e43e577()

                    mfc90d.dll!CWnd::DefWindowProcA(unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 1043 + 0x20 bytes C++
                    mfc90d.dll!CWnd::Default() Line 274 C++
                    mfc90d.dll!CDialog::HandleInitDialog(unsigned int __formal=723394, unsigned int __formal=723394) Line 673 + 0x8 bytes C++
                    mfc90d.dll!CWnd::OnWndMsg(unsigned int message=272, unsigned int wParam=723394, long lParam=0, long * pResult=0x0013e2dc) Line 2018 + 0x11 bytes C++
                    mfc90d.dll!CWnd::WindowProc(unsigned int message=272, unsigned int wParam=723394, long lParam=0) Line 1755 + 0x20 bytes C++
                    mfc90d.dll!AfxCallWndProc(CWnd * pWnd=0x0013e7b4, HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 240 + 0x1c bytes C++
                    mfc90d.dll!AfxWndProc(HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 403 C++
                    mfc90d.dll!AfxWndProcBase(HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 441 + 0x15 bytes C++
                    user32.dll!7e418734()
                    user32.dll!7e418816()
                    user32.dll!7e42927b()
                    user32.dll!7e42651a()
                    user32.dll!7e42683e()
                    user32.dll!7e439b43()
                    mfc90d.dll!CWnd::CreateDlgIndirect(const DLGTEMPLATE * lpDialogTemplate=0x00480aa0, CWnd * pParentWnd=0x00000000, HINSTANCE__ * hInst=0x00400000) Line 312 + 0x2a bytes C++
                    mfc90d.dll!CDialog::DoModal() Line 576 + 0x20 bytes C++
                    MFCTest.exe!CMFCTestApp::InitInstance() Line 63 + 0xb bytes C++
                    mfc90d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00161f0a, int nCmdShow=1) Line 37 + 0xd bytes C++
                    MFCTest.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00161f0a, int nCmdShow=1) Line 30 C++
                    MFCTest.exe!__tmainCRTStartup() Line 574 + 0x35 bytes C
                    MFCTest.exe!WinMainCRTStart

                    G Offline
                    G Offline
                    Grahamfff
                    wrote on last edited by
                    #9

                    Dear Jessica, thank you for your e-mail of the 15th April 2013. I would just like to confirm that I would like to know what happened to my complaint that I submitted to Ian Clarke on the 16th of June 2011 via e-mail. The details of the complaint have already been sent to you regarding this electoral fraud issue. Also I would like to understand how the complaint from the Town Clerk of Chard was progressed as I said before it did not follow the documented process contained on SSDC web site. This complaint was lodged by the Chard Town Clerk to your Monitoring officer Ian Clarke dated the 16th of June 2012. This complaint was not lodged in the formal system of complaints and I was later informed of this complaint on the 31st of July some six weeks later by what it seems private correspondence and again there appears to be two separate audit trains on this issue. If I need to resubmit my complaint of the 16th June 2011 then I would like your advice on this so that this and any future complaints can be progressed and not ‘lost in the system’ by some strange progress’. Also I feel that the complaint lodged by Chard Town Clerk was not handled correctly and so how would I instigate a complaint against the Monitoring Officer regarding this issue as if I do this directly then it could again get ’lost’ in the system. What I am thinking is can I copy the complaint into another individual to ensure that it does not get deleted on arrival? Regarding the possible FOI over the display of Countryside Alliance posters in my Polling Station in May 2011, I am happy not to continue with this issue even though I did not get any acknowledgement or apology over this issue, but perhaps the Democrat Services department may have learned their lesson, I do hope so! As for the Subject Access Request, I shall take legal advice which will probably result in writing to the Information Commissioner for a ruling over this data request. Many thanks for your assistance and look forward to receiving your advice, Graham Forsyth.

                    grahamfff

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups