CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: LookupPermanent

  1. #1
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60

    LookupPermanent

    I am testing program in Debug Mode, the program seem fine because It has ran well for over 12 hours. But this morning, The program crashed, the I saw the CallStack, here is the last break point:

    CWnd* PASCAL CWnd::FromHandlePermanent(HWND hWnd)
    {
    CHandleMap* pMap = afxMapHWND();
    CWnd* pWnd = NULL;
    if (pMap != NULL)
    {
    // only look in the permanent map - does no allocations
    pWnd = (CWnd*)pMap->LookupPermanent(hWnd);

    ASSERT(pWnd == NULL || pWnd->m_hWnd == hWnd); (WINCORE.CPP line 304)Program crashes here because:
    pWnd = 0x0146c2e8 , hWnd = 0x002107c8 and pWnd->m_hWnd = 0x00000036

    }
    return pWnd;
    }
    And here are call stacks:
    CWnd::FromHandlePermanent(HWND__ * 0x002107c8) line 304 + 32 bytes
    CWnd::SendMessageToDescendants(HWND__ * 0x001306c4, unsigned int 126, unsigned int 32, long 67110144, int 1, int 1) line 2302 + 9 bytes
    CWnd::SendMessageToDescendants(HWND__ * 0x003d01a8, unsigned int 126, unsigned int 32, long 67110144, int 1, int 1) line 2320
    CWnd::SendMessageToDescendants(unsigned int 126, unsigned int 32, long 67110144, int 1, int 1) line 146 + 32 bytes
    CWnd::OnDisplayChange(unsigned int 32, unsigned int 32) line 2965
    CWnd::OnWndMsg(unsigned int 126, unsigned int 32, long 67110144, long * 0x00128c08) line 1815 + 17 bytes
    CWnd::WindowProc(unsigned int 126, unsigned int 32, long 67110144) line 1585 + 30 bytes
    CDDSCenterDlg::WindowProc(unsigned int 126, unsigned int 32, long 67110144) line 612
    AfxCallWndProc(CWnd * 0x0012dbc4 {CDDSCenterDlg hWnd=???}, HWND__ * 0x003d01a8, unsigned int 126, unsigned int 32, long 67110144) line 215 + 26 bytes
    AfxWndProc(HWND__ * 0x003d01a8, unsigned int 126, unsigned int 32, long 67110144) line 368
    AfxWndProcBase(HWND__ * 0x003d01a8, unsigned int 126, unsigned int 32, long 67110144) line 220 + 21 bytes
    USER32! 77d43a50()


    I know this is difficult to find cause(s) with this information. Do you ever met this error, and how to solve it. If not, do you have any ideas round this error: possible cause(s). I checked memory leak and memory overwritting carefully, but it may be my mistake. Thanks for any helps.
    Quang

  2. #2
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60
    In my program I use only one Thread for Serial Communication, so I am not passing a CWnd* across threads.

    http://www.codeguru.com/forum/showth...hreadid=268651
    Quang

  3. #3
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60
    Do you have any ideas?
    Quang

  4. #4
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    I see that the message being processed was WM_DISPLAYCHANGE. Did you see that?
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  5. #5
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60
    MSDN wrote:
    The WM_DISPLAYCHANGE message is sent to all windows when the display resolution has changed.

    A window receives this message through its WindowProc function.
    I think that my program has memory overwrite bug(s). Because program crashed at 6.0AM where we were all deep in sleep, and the resolution has been kept unchanged since a month ago.

    When WindowProc is called, the message is overwritten unintentionally, and the message turned into WM_DISPLAYCHANGE. The program call successive functions correponding to WM_DISPLAYCHANGE(infact, the message is not WM_DISPLAYCHANGE). This is why the program crashed. Do I think right? Now I am checking my program more carefully.

    Thanks Sam Hobbs for your suggestion. Any other ideas will be highly appreciated.
    Quang

  6. #6
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    Probably you are correct that memory is being written over incorrectly (clobbered). Therefore it is probably very difficult for us to help. You are sufficiently knowledgeable enough to know what to look for. We can understand your frustration though.

    Oh, I suppose we can help a bit. If you are not familiar with use of breakpoints for this, it is possible to set a breakpoint on the condition that a memory location changes. However that won't help if you must run the program for many hours before it reaches the breakpoint, since performance is so degraded by the breakpoint.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  7. #7
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60
    Thank Sam Hobbs again. I think break point to check memory is not a good solution for a my program because of reasons you said. So I will try other solutions.
    Quang

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