请教各位高手:
MFC SDI在退出的时候,总是报 user break call from ..., debug output:
Free Heap block 345b50 modified at 345e38 after it was freed调试时在0x345b50上设置data breakpoint,有两次中断:第一次:
NTDLL! RtlpCoalesceFreeBlocks@16 + 945 bytes
NTDLL! RtlFreeHeapSlowly@12 + 371 bytes
NTDLL! RtlDebugFreeHeap@12 + 416 bytes
NTDLL! RtlFreeHeapSlowly@12 + 77 bytes
NTDLL! RtlFreeHeap@12 + 133 bytes
_free_base(void * 0x00345b58) line 96
_free_dbg_lk(void * 0x00345b78, int 4) line 1116 + 9 bytes
_free_dbg(void * 0x00345b78, int 4) line 1001 + 13 bytes
CObject::operator delete(void * 0x00345b78) line 46 + 12 bytes
CMainFrame::`scalar deleting destructor'(unsigned int 1) + 56 bytes
CFrameWnd::PostNcDestroy() line 214 + 31 bytes
CWnd::OnNcDestroy() line 854
CWnd::OnWndMsg(unsigned int 130, unsigned int 0, long 0, long * 0x0012f058) line 1836
CWnd::WindowProc(unsigned int 130, unsigned int 0, long 0) line 1596 + 30 bytes
AfxCallWndProc(CWnd * 0x00345b78 {CWnd hWnd=0xdddddddd}, HWND__ * 0x00120928, unsigned int 130, unsigned int 0, long 0) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x00120928, unsigned int 130, unsigned int 0, long 0) line 379
AfxWndProcBase(HWND__ * 0x00120928, unsigned int 130, unsigned int 0, long 0) line 220 + 21 bytes
USER32! UserCallWinProc@20 + 24 bytes
USER32! CallWindowProcAorW@24 + 69 bytes
USER32! CallWindowProcA@20 + 25 bytes
HookWndProc(HWND__ * 0x00120928, unsigned int 130, unsigned int 0, long 0) line 161 + 28 bytes
USER32! UserCallWinProc@20 + 24 bytes
USER32! DispatchClientMessage@20 + 51 bytes
USER32! __fnDWORD@4 + 34 bytes
NTDLL! KiUserCallbackDispatcher@12 + 19 bytes
SMSLISTENER! @ILT+2750(?HookWndProc@@YGJPAUHWND__@@IIJ@Z) address 0x00401ac3
CDocument::OnCloseDocument() line 801
CDocTemplate::CloseAllDocuments(int 0) line 357
CDocManager::CloseAllDocuments(int 0) line 569
CWinApp::CloseAllDocuments(int 0) line 99
CFrameWnd::OnClose() line 805
CMainFrame::OnClose() line 154
CWnd::OnWndMsg(unsigned int 16, unsigned int 0, long 0, long * 0x0012f4d4) line 1836
CWnd::WindowProc(unsigned int 16, unsigned int 0, long 0) line 1596 + 30 bytes
AfxCallWndProc(CWnd * 0x00345b78 {CWnd hWnd=0xdddddddd}, HWND__ * 0x00120928, unsigned int 16, unsigned int 0, long 0) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x00120928, unsigned int 16, unsigned int 0, long 0) line 379
AfxWndProcBase(HWND__ * 0x00120928, unsigned int 16, unsigned int 0, long 0) line 220 + 21 bytes
USER32! UserCallWinProc@20 + 24 bytes
USER32! CallWindowProcAorW@24 + 69 bytes
USER32! CallWindowProcA@20 + 25 bytes
CSubclassWnd::WindowProc(unsigned int 16, unsigned int 0, long 0) line 90 + 86 bytes
CTrayIcon::CTrayHook::WindowProc(unsigned int 16, unsigned int 0, long 0) line 138
HookWndProc(HWND__ * 0x00120928, unsigned int 16, unsigned int 0, long 0) line 165 + 25 bytes
USER32! UserCallWinProc@20 + 24 bytes
USER32! DispatchClientMessage@20 + 51 bytes
USER32! __fnDWORD@4 + 34 bytes
NTDLL! KiUserCallbackDispatcher@12 + 19 bytes
SMSLISTENER! @ILT+2750(?HookWndProc@@YGJPAUHWND__@@IIJ@Z) address 0x00401ac3
USER32! SendMessageA@16 + 71 bytes
CWnd::SendMessageA(unsigned int 16, unsigned int 0, long 0) line 39 + 75 bytes
CMainFrame::OnAppSuspend() line 180
_AfxDispatchCmdMsg(CCmdTarget * 0x00345b78 {CCmdTarget}, unsigned int 32774, int 0, void (void)* 0x004011ef CMainFrame::OnAppSuspend(void), void * 0x00000000, unsigned int 12, AFX_CMDHANDLERINFO * 0x00000000) line 88
CCmdTarget::OnCmdMsg(unsigned int 32774, int 0, void * 0x00000000, AFX_CMDHANDLERINFO * 0x00000000) line 302 + 39 bytes
CFrameWnd::OnCmdMsg(unsigned int 32774, int 0, void * 0x00000000, AFX_CMDHANDLERINFO * 0x00000000) line 898 + 24 bytes
CWnd::OnCommand(unsigned int 32774, long 0) line 2099
CFrameWnd::OnCommand(unsigned int 32774, long 0) line 321
CWnd::OnWndMsg(unsigned int 273, unsigned int 32774, long 0, long * 0x0012fb4c) line 1608 + 28 bytes
CWnd::WindowProc(unsigned int 273, unsigned int 32774, long 0) line 1596 + 30 bytes
AfxCallWndProc(CWnd * 0x00345b78 {CWnd hWnd=0xdddddddd}, HWND__ * 0x00120928, unsigned int 273, unsigned int 32774, long 0) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x00120928, unsigned int 273, unsigned int 32774, long 0) line 379
AfxWndProcBase(HWND__ * 0x00120928, unsigned int 273, unsigned int 32774, long 0) line 220 + 21 bytes
USER32! UserCallWinProc@20 + 24 bytes
USER32! CallWindowProcAorW@24 + 69 bytes
USER32! CallWindowProcA@20 + 25 bytes
CSubclassWnd::WindowProc(unsigned int 273, unsigned int 32774, long 0) line 90 + 86 bytes
CTrayIcon::CTrayHook::WindowProc(unsigned int 273, unsigned int 32774, long 0) line 138
HookWndProc(HWND__ * 0x00120928, unsigned int 273, unsigned int 32774, long 0) line 165 + 25 bytes
USER32! UserCallWinProc@20 + 24 bytes
USER32! DispatchMessageWorker@8 + 264 bytes
USER32! DispatchMessageA@4 + 11 bytes
CWinThread::PumpMessage() line 853
CWinThread::Run() line 487 + 11 bytes
CWinApp::Run() line 400
AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00132f53, int 1) line 49 + 11 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00132f53, int 1) line 30
WinMainCRTStartup() line 330 + 54 bytes
KERNEL32! BaseProcessSta
第二次,即出现user break的时候:
NTDLL! DbgBreakPoint@0 address 0x77f9193c
NTDLL! RtlpBreakPointHeap@4 + 38 bytes
NTDLL! RtlpValidateHeap@8 + 828 bytes
NTDLL! RtlValidateHeap@12 + 235 bytes
NTDLL! RtlValidateProcessHeaps@0 + 121 bytes
NTDLL! LdrShutdownProcess@0 + 191 bytes
KERNEL32! ExitProcess@4 + 81 bytes
doexit(int 0, int 0, int 0) line 392
exit(int 0) line 279 + 13 bytes
WinMainCRTStartup() line 345
KERNEL32! BaseProcessStart@4 + 61 bytes不知是什么原因?谢谢。

解决方案 »

  1.   

    是在CRT里的,调用kernel32的ExitProcess是出的错。
      

  2.   

    貌似是你的CMainFrame被删除了两次
      

  3.   

    to analyst:
    怎么看出来的?
    to syy64:
    查过了,没有查到。
      

  4.   

    实际上这个现象只有在IDE环境调试时才有,脱离IDE运行就没什么现象。
      

  5.   

    你可以装个bounds checker来帮助你检查。
      

  6.   

    bounds checker没有提示这个错误,只有些乱哄哄的内存泄漏(MFC源代码里的)
      

  7.   

    应该是缓冲越界,操作系统回收内存的错误.
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vcce4/html/evconSolvingBufferOverwritesandMemoryLeaks.asp
      

  8.   

    应该是内存堆的问题,好像是重写了delete过的内存,但是查了半天也没找到错,我都怀疑编译器是不是坏了;)
      

  9.   

    呵呵,在调用CFrameWnd::OnClose();后又写了成员变量。
    3x for all