c++ – How can I debug an exception thrown in ucrtbased.dll?


I have a legacy application I’m working with which has hundreds of thousands of lines of C++ code. I am updating it to the latest version of Visual Studio, Windows SDK, etc.

The application runs fine but in a debug build on exit I get an exception:

Exception thrown at 0x560C9A11 (ucrtbased.dll) in app.exe: 0xC0000005: Access violation reading location 0xFFFFFFFC.

The call stack is:
enter image description here

The disassembly around this line of code is:

560C99EE  mov         dword ptr [ebp-2Ch],eax  
560C99F1  mov         ecx,dword ptr [ebp-18h]  
560C99F4  mov         dword ptr [ebp-20h],ecx  
560C99F7  mov         edx,dword ptr [ebp-14h]  
560C99FA  mov         dword ptr [ebp-24h],edx  
560C99FD  mov         eax,dword ptr [ebp-14h]  
560C9A00  sub         eax,4  
560C9A03  mov         dword ptr [ebp-14h],eax  
560C9A06  mov         ecx,dword ptr [ebp-14h]  
560C9A09  cmp         ecx,dword ptr [ebp-18h]  
560C9A0C  jb          560C9A1A  
560C9A0E  mov         edx,dword ptr [ebp-14h]  
560C9A11  mov         eax,dword ptr [edx]  
560C9A13  cmp         eax,dword ptr [ebp-2Ch]  
560C9A16  jne         560C9A1A  
560C9A18  jmp         560C99FD  
560C9A1A  mov         ecx,dword ptr [ebp-14h]  
560C9A1D  cmp         ecx,dword ptr [ebp-18h]  
560C9A20  jae         560C9A27  
560C9A22  jmp         560C9AAA  
560C9A27  mov         edx,dword ptr [ebp-14h]  
560C9A2A  mov         eax,dword ptr [edx]  
560C9A2C  push        eax  
560C9A2D  call        560AFA70  

I inherited this code base. We don’t have a lot of history in our repo. The initial commit also throws this same exception. So I can’t just go back and binary search through commits to see where it crept in. I’m guessing the exception didn’t happen in a previous version of Windows. This code base goes back to the early 2000s.

How do I go about debugging this?

Leave a Reply

Your email address will not be published. Required fields are marked *