【问题标题】:Migrated application crashes, if DEP is active如果 DEP 处于活动状态,迁移的应用程序崩溃
【发布时间】:2012-05-15 07:36:39
【问题描述】:

我已将我们的 MFC 应用程序从 vc6 移植到 vc9 (VS2008)。一切都很好,但如果 DEP 处于活动状态,程序会崩溃(下面的堆栈跟踪)。我已经尝试过使用 NX-Flag,但没有任何改变。我还尝试使用 Parasoft Insure++ 构建应用程序,但没有显示内存损坏或任何其他问题。

提前感谢您的任何建议。

环境如下:

  • DEP 选项为 NoExecute=OptOut,程序在排除列表中(如果不是,它不会崩溃,但还有其他问题)。
  • MFC MainFrame 代码在 dll 中,而不是在 exe 中
  • 如果 DEP 处于活动状态,一些旧的第 3 方 ActiveX 组件将无法工作

堆栈跟踪:

>   mfc90d.dll!CThemeHelper::IsAppThemed()  Zeile 82    C++
    mfc90d.dll!CControlBar::OnCreate(tagCREATESTRUCTA * lpcs=0x00dde2b4)  Zeile 576 + 0x5 Bytes C++
    mfc90d.dll!CWnd::OnWndMsg(unsigned int message=1, unsigned int wParam=0, long lParam=14541492, long * pResult=0x00dde05c)  Zeile 2014 + 0xd Bytes   C++
    mfc90d.dll!CWnd::WindowProc(unsigned int message=1, unsigned int wParam=0, long lParam=14541492)  Zeile 1755 + 0x20 Bytes   C++
    mfc90d.dll!CControlBar::WindowProc(unsigned int nMsg=1, unsigned int wParam=0, long lParam=14541492)  Zeile 506 + 0x14 Bytes    C++
    mfc90d.dll!AfxCallWndProc(CWnd * pWnd=0x01ba3d80, HWND__ * hWnd=0x000b1110, unsigned int nMsg=1, unsigned int wParam=0, long lParam=14541492)  Zeile 240 + 0x1c Bytes   C++
    mfc90d.dll!AfxWndProc(HWND__ * hWnd=0x000b1110, unsigned int nMsg=1, unsigned int wParam=0, long lParam=14541492)  Zeile 403    C++
    bedamain.dll!AfxWndProcDllStatic(HWND__ * hWnd=0x000b1110, unsigned int nMsg=1, unsigned int wParam=0, long lParam=14541492)  Zeile 54 + 0x15 Bytes C++
        ...
    user32.dll!7e37e34f()   
    mfc90d.dll!CWnd::WindowProc(unsigned int message=1, unsigned int wParam=643120, long lParam=463138)  Zeile 1755 + 0x20 Bytes    C++
    mfc90d.dll!AfxGetModuleThreadState()  Zeile 498 + 0x11 Bytes    C++
    kernel32.dll!7c80a73d()     
    mfc90d.dll!AfxDeactivateActCtx(unsigned long dwFlags=0, unsigned long ulCookie=495452227)  Zeile 260 + 0x17 Bytes   C++
    mfc90d.dll!AFX_MAINTAIN_STATE2::~AFX_MAINTAIN_STATE2()  Zeile 63 + 0xe Bytes    C++
    bedamain.dll!AfxWndProcDllStatic(HWND__ * hWnd=0x00071122, unsigned int nMsg=5, unsigned int wParam=0, long lParam=43648228)  Zeile 54 + 0x27 Bytes C++
        ...
    user32.dll!7e37c17e()   
    mfc90d.dll!CWnd::DefWindowProcA(unsigned int nMsg=71, unsigned int wParam=48, long lParam=643672)  Zeile 1043 + 0x20 Bytes  C++
    mfc90d.dll!CWnd::WindowProc(unsigned int message=1, unsigned int wParam=14542916, long lParam=2024004508)  Zeile 1756 + 0x1c Bytes  C++
        ...
    user32.dll!7e37e4dc()   
    mfc90d.dll!AfxCtxCreateWindowExA(unsigned long dwExStyle=512, const char * lpClassName=0x00067b58, const char * lpWindowName=0x78a44e50, unsigned long dwStyle=13565952, int X=-2147483648, int Y=-2147483648, int nWidth=-2147483648, int nHeight=-2147483648, HWND__ * hWndParent=0x00000000, HMENU__ * hMenu=0x028d090d, HINSTANCE__ * hInstance=0x10000000, void * lpParam=0x00ddf644)  Zeile 438 + 0xa3 Bytes  C++
    mfc90d.dll!CWnd::CreateEx(unsigned long dwExStyle=0, const char * lpszClassName=0x00067b58, const char * lpszWindowName=0x78a44e50, unsigned long dwStyle=13598720, int x=-2147483648, int y=-2147483648, int nWidth=-2147483648, int nHeight=-2147483648, HWND__ * hWndParent=0x00000000, HMENU__ * nIDorHMenu=0x028d090d, void * lpParam=0x00ddf644)  Zeile 708 + 0x35 Bytes  C++
    mfc90d.dll!CFrameWnd::Create(const char * lpszClassName=0x00067b58, const char * lpszWindowName=0x78a44e50, unsigned long dwStyle=13598720, const tagRECT & rect={...}, CWnd * pParentWnd=0x00000000, const char * lpszMenuName=0x000003ec, unsigned long dwExStyle=0, CCreateContext * pContext=0x00ddf644)  Zeile 608 + 0x54 Bytes    C++
    mfc90d.dll!CFrameWnd::LoadFrame(unsigned int nIDResource=1004, unsigned long dwDefaultStyle=13598720, CWnd * pParentWnd=0x00000000, CCreateContext * pContext=0x00ddf644)  Zeile 740 + 0x35 Bytes   C++
    mfc90d.dll!CDocTemplate::CreateNewFrame(CDocument * pDoc=0x01ba39c8, CFrameWnd * pOther=0x00000000)  Zeile 277 + 0x22 Bytes C++
    mfc90d.dll!CSingleDocTemplate::OpenDocumentFile(const char * lpszPathName=0x00000000, int bMakeVisible=1)  Zeile 125 + 0x13 Bytes   C++
    mfc90d.dll!CDocManager::OnFileNew()  Zeile 848  C++
    mfc90d.dll!CWinApp::OnFileNew()  Zeile 22   C++
    mfc90d.dll!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x10111a48, unsigned int nID=57600, int nCode=0, void (void)* pfn=0x100a5a18, void * pExtra=0x00000000, unsigned int nSig=57, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000)  Zeile 82    C++
    mfc90d.dll!CCmdTarget::OnCmdMsg(unsigned int nID=57600, int nCode=0, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000)  Zeile 381 + 0x27 Bytes    C++
    mfc90d.dll!CWinApp::ProcessShellCommand(CCommandLineInfo & rCmdInfo={...})  Zeile 24 + 0x20 Bytes   C++
    bedamain.dll!CBeDaMainApp::InitInstance()  Zeile 261 + 0xc Bytes    C++
    bedamain.dll!InternalDllMain(HINSTANCE__ * hInstance=0x10000000, unsigned long dwReason=1, void * __formal=0x00ddfd30)  Zeile 100 + 0x13 Bytes  C++
    bedamain.dll!DllMain(HINSTANCE__ * hInstance=0x10000000, unsigned long dwReason=1, void * lpReserved=0x00ddfd30)  Zeile 272 C++
    bedamain.dll!__DllMainCRTStartup(void * hDllHandle=0x10000000, unsigned long dwReason=1, void * lpreserved=0x00ddfd30)  Zeile 546 + 0x11 Bytes  C
    bedamain.dll!_DllMainCRTStartup(void * hDllHandle=0x10000000, unsigned long dwReason=1, void * lpreserved=0x00ddfd30)  Zeile 510 + 0x11 Bytes   C
        ...
    ntdll.dll!7c928b7b()    

【问题讨论】:

  • There are some old 3rd-party ActiveX components, which do not work, if DEP is active。这不是你的答案吗?
  • 我认为不是。它将稍后加载,但崩溃发生在启动期间。得到了解决方法:通过 LoadLibrary 加载 dll。但我还是想知道,怎么了。

标签: c++ mfc visual-c++-6 visual-c++-2008 dep


【解决方案1】:

看起来好像您的 ActiveX 组件正在堆栈上执行代码(因此 DEP 失败)。

【讨论】:

  • 如前所述,崩溃时没有加载 ActiveX 组件。
  • 没问题。解决方法工作正常。由此得出结论,由于 DEP,系统 dll 加载存在一些延迟。现在我遇到了另一个问题:应用程序在退出时挂起 :(
猜你喜欢
  • 2020-08-14
  • 1970-01-01
  • 1970-01-01
  • 2011-06-11
  • 1970-01-01
  • 2012-06-04
  • 2015-03-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多