How to trace an unhandled exception in C++ using Visual Studio 2017 - c++

I am currently working on fixing a project for a client. A little information about the project first:
Originally developed in Visual Studio 2012 using xp_v110 build tools
Multiple projects in the solution
Currently updating/debugging in Visual Studio 2017 using VS 2015/xp_v140 build tools
Working on Windows 10
The application will run in debug mode, however if I just leave the application after starting the debug session (i.e. not opening/clicking on the application to open it as it starts minimized in the tray), the application crashes after 1-2 minutes.
Unfortunately the IDE is showing that the crash is taking place in chkstk.asm with the following message:
Exception thrown at 0x0064EDF9 in <<exe name>>: 0xC00000FD: Stack overflow (parameters 0x00000000, 0x000A2000).
I have updated the exception settings to break when all C++ Exceptions are thrown, checked the box that says "Break when this exception type is thrown", and wrapped the initial method that runs in a try block, however I can never catch the error in the C++ code; it always occurs in the chkstk.asm file.
Any suggestions on how I can find out where in the C++ code the exception is occurring. Like I said, this is an update for a client and the original programmer is not available, and they never commented their code, so it is difficult enough trying to go through all this. Any help/suggestions would be greatly appreciated. Thanks in advance.

Related

How do I debug an application crash (unhandled win32 exception) in vscode?

I have a running application that crashes with "An unhandled win32 exception occurred in ..." dialog. This only contains full-fledged Visual Studio in the available debuggers list even though Visual Studio Code is installed.
I would rather use vscode as it is my main dev environment.
How can I add it to the "Choose Just-In-Time Debugger" window's "Available Debuggers" list?
Update:
I found where the setting exists in the registry, with an example of how to set WinDbg as the debugger instead of Visual Studio.
https://www.codeproject.com/articles/6084/windows-debuggers-part-1-a-windbg-tutorial#_Toc64133667
and
https://learn.microsoft.com/en-us/windows/win32/debug/configuring-automatic-debugging
Remaining step is to determine how VS Code's debugger likes to be invoked.
(I'm still open to cleaner ways to do this, however.)
Update 2:
Nearest I can tell, this last step is the big deal breaker.
According to this feature request:
https://github.com/Microsoft/vscode/issues/10979
It doesn't look like the team at Microsoft is interested in making that an option. :_(

unhandled exception access violation C++ Visual Studio before main is called

I'm getting the following error as soon as I click run to debug in Visual Studio 2013 . . .
I'm not sure how to proceed as I put a breakpoint on the first step in main and it does not hit this breakpoint.
History: I was handed a working program and was asked to integrate an updated dll. The dll had a couple I/O changes which I updated in the wrapper to enable the program to build. Now when I run I get the mentioned error.
Any next step advice as to what to check from here?

QT and heap corruption

I understand that heap corruption can happen from wide variety of causes.
I have a QT C++ project in Visual Studio. If I run in Debug or Release mode from Visual Studio, everything goes smoothly.
If I run the released executable (outside of Visual Studio), I get an application has stopped working error, followed by a prompt that asks if I want to Debug. This brings up Visual Studio Just-in-Time Debugger window stating that: An unhandled win32 exception occured in my_qt_application.exe[8812]
If I choose to Debug, I get the message: Unhandled exception at (...) (ntdll.dll) (...) A heap has been corrupted.
So I keep searching in the code for causes. The problem is that this error happens at very random occasions, not very consistent.
My question is; can the cause of this be missing dlls? (I've added the dlls that allows the program to run.)
No. The cause cannot be missing dlls. It could be a proximate cause. Example: If some image plugins are not available, and your code doesn't check that QImage loading had succeeded, and then tries to operate on the null image - there may be problems.
Most likely, though, you have a plain old memory error that you should squish using e.g. Valgrind.

How do I get stack trace in Visual Studio 2017

I am getting Exceptions in the Output window of Visual Studio but do not know what code is causing these exceptions. I would like to get a stack trace so I can properly debug them.
Here is a sample of the exceptions I am getting:
The one I am particularly interested in in the NullReferenceException.
I have looked at this SO post:
How do I find the stack trace in Visual Studio?
But my menu looks like this:
I tried to follow these instructions for adding the "Exceptions" choice to the Debug menu but all I can find it "Exceptions Settings":
Seeing a stack trace of an exceptions seems like such a common need I have a hard time believing that VS is hiding it.
I noticed a tabbed panel on the bottom of VS and was able to modify the Exceptions that cause VS to break on the "Exception Settings" tab.

I get FatalExecutionEngineError when I am debugging unit test with Resharper on visual studio

I keep getting this error message when I am trying to debug through my project. The same code works on colleges machine. I currently use Windows 8.1 and resharper 8.2 and after initial few methods within a selenium test. I am also using VMware workstation 10.0.4
FatalExecutionEngineError occurred
Message: Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in
'C:\Program Files (x86)\JetBrains\ReSharper\v8.2\Bin\JetBrains.ReSharper.TaskRunner.CLR45.x64.exe'.
Additional information: The runtime has encountered a fatal error.
The address of the error was at 0x7d608056, on thread 0xfb8. The error code is 0xc0000005.
This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code.
Common sources of this bug include user marshaling errors for COM-interop or PInvoke,
which may corrupt the stack.
Try with stopping the Re-Sharper plugin. If it start to work after disable of Re-Sharper from Visual Studio then uninstall and install re-sharper.
When i turn off breaking on all exceptions in VS (Ctrl+Alt+E), debugging becames available.