0

I have a crash that is caught in Sentry.

CWnd::IsWindowVisible Unhandled Fatal Error: EXCEPTION_ACCESS_VIOLATION_READ

I downloaded the mini dump file (dmp) and ran through Visual Studio 19. The crash is occurring in the method:

BOOL CWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)

I'm including a screen shot because one of my questions is:

Where exactly is the crash? Is the line (screenshot) really representing the crash?

Using the debugger I can see that the parameter message coming into the method is 275 which is

0113        275     WM_TIMER

See for example: https://wiki.winehq.org/List_Of_Windows_Messages. My questions:

  1. Where exactly is the crash? I don't see how checking for pResult being NULL and assigning lResult to *pResult could cause a crash of any kind and certainly not EXCEPTION_ACCESS_VIOLATION_READ
  2. In anticipation of somebody stating that the exception is actually elsewhere... a. How do I get the exact location/problem from the dump b. Anyone recognize this type of problem with TIMERS? It's not my code, but I'm already imagining such things as multiple stops of timers, doing something to a Window that no longer exists, etc. Based on EXCEPTION_ACCESS_VIOLATION_READ
  3. Any clues/ideas how to proceed?

As always, if better asked in another group, or more clarification needed, please let me know. And Thanks!

EDIT - ADDITIONAL INFO Note that Sentry says the program is actually crashing on IsWindowVisible. That certainly isn't present in debugging the dump file (that I can see) and the point of crash as shown by the screen shot doesn't show it, but it might make sense. The OnTimer routine certainly mentions IsWindowVisible().

4. Can IsWindowVisible() crash with EXCEPTION_ACCESS_VIOLATION_READ ?

enter image description here

Dave
  • 8,095
  • 14
  • 56
  • 99
  • 1
    If you can reproduce the issue, try building with the [`/Zo`](https://learn.microsoft.com/en-us/cpp/build/reference/zo-enhance-optimized-debugging) compiler option. The location displayed cannot raise an `EXCEPTION_ACCESS_VIOLATION_READ`. – IInspectable Jan 06 '22 at 22:26
  • Thanks for the quick comment @IInspectable ! Unfortunately, I can't duplicate. It's about 6 of 100 or so customers and only occasionally. I'm guessing it's some sort of timing issue. And I agree that the location displayed cannot raise this exception. Google searches for EXCEPTION_ACCESS_VIOLATION_READ and timers AND IsWindowVisible suggest the timer code (OnTimer(...)) might be playing with non-existent window handles or similar. I'll edit question to bring out this point. – Dave Jan 07 '22 at 00:45
  • Non-existent window handles aren't an issue. They will not trigger Access Violation exceptions. What you have instead is a C++ library that wraps window handles (plus other data). If anything, it's one of those C++ wrappers that are gone that would trigger an AV. The address surely looks like a null pointer deref, possibly a `this` pointer of a dead object, plus a 32 byte offset to reach member data. – IInspectable Jan 07 '22 at 00:53
  • *"Can IsWindowVisible()"* - That depends. If this is the Windows API call [`IsWindowVisible`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-iswindowvisible), then no, this cannot crash (or otherwise fail). If this is a class member (such as [`CWnd::IsWindowVisible`](https://learn.microsoft.com/en-us/cpp/mfc/reference/cwnd-class#iswindowvisible)) then that can fail when accessing the member variable. – IInspectable Jan 07 '22 at 09:56
  • @IInspectable It's being called as GetParent()->IsWindowVisible() AND as AfxGetMainWnd()->IsWindowVisible() . It certainly could be crashing here. It would be nice if the call stack reflected that rather than "if (pResult != NULL)...." If I assume that the pointer returned from GetParent() or AfxGetMainWnd is null or corrupted, would that explain the "CWnd::IsWindowVisible Unhandled Fatal Error: EXCEPTION_ACCESS_VIOLATION_READ" mentioned at the top of the Sentry post? – Dave Jan 07 '22 at 15:43
  • I suppose my next step will be to figure out why the pointer is NULL/corrupt. As a stop gap or for additional debugging, I could throw a try/catch around the IsWindowVisible calls. @IInspectable Finally, can you throw your existing comments in an answer (and any more you care to give! :)) , so I can accept it? Thanks! – Dave Jan 07 '22 at 15:44

0 Answers0