disable error popup in visual studio - c++

I keep getting the following error in visual studio:
http://i.stack.imgur.com/qKyk8.png
However if I click continue my application runs perfectly fine, every time I run it it does this. As you can imagine this is incredibly annoying. I have gone through the exception settings to try and find something under runtime, error, runtime_error, std and so on. I was not able to find anything that matched the description of the error. Additionally I have no idea what is causing this to popup in the first place, as how am I supposed to know what is using that memory location?

You can disable it by properly handling the cause of the exception being thrown. Debug your code to find what is causing the exception.

Try going to exception settings, add new C++ exception: std::runtime_error and uncheck it. Or just stop breaking in any C++ exceptions at all.

Related

How do I find the location of a "vector subscript out of range" error? C++ Visual Studio

I am quite new to coding. I know what "vector subscript out of range" means, how it occures and how to fix it. But I have many many vectors in my code and often get this error. But when this error hits I always get this error box you all know. And it says "Hit retry to debug your application". And when I click it it brings me to line 1731 in the "vector" file. But how do I get to the point (the line or the file) in my code, where I created this error???
I tried using the Debug-Navigation in VisualStudio to move back and forth to get to my code. But this doesn't work. Thanks for your help in advance.
You should be able to find the problematic place from the call stack. There you can go up and down the stack by double-clicking the corresponding line and check the Autos and Locals debugging windows (https://learn.microsoft.com/en-us/visualstudio/debugger/autos-and-locals-windows?view=vs-2022).
The problem you might have is that you are getting into the debugger too late, when the exception is unhandled (there were no try/catch blocks able to handle this, so it was caught by the C++ infrastructure). Check Debug->Windows->Exception Settings window and set the exception you get to break when the exception is thrown (not unhandled).

Visual Studio - *.exe has triggered a breakpoint - despite no "break with thrown" enabled

I have a large MFC project I'm debugging in visual studio 2017. I recently upgraded the code to 64 bit from 32 bit. Now, when I press a certain hotkey, I get an exception raised before the program enters the code that I wrote to handle the hotkey.
As I understand it, this means that somewhere some sort of exception was thrown and caught (if it wasn't caught I should have gotten a "unhandled exception" error) and visual studio thinks I might like to know that. For some reason it doesn't tell me what type of exception was thrown, and as far as I can tell I have no way of finding that out. The VS debugger breaks in some external assembly code:
Importantly, under exception settings I have all "break when thrown" options disabled:
and if I uncheck the "Break when this exception type is thrown" box in the "Exception Thrown" window, nothing happens, and the next time I hit the hot key the exception is thrown again and the box has a check again. I'm a bit lost in where to go from here. Unfortunately the project is quite large and I can't simplify it to make a minimal reproducible example. If anyone has any ideas or advice, I would be forever grateful. How can I get rid of this visual studio alert?

How to avoid "program.exe has stopped working" window in release mode on windows?

I'm working on the development of a software in C++ on Visual Studio 2010. As this software should be run on servers where human interaction is not available, I really really need to get rid of this "program.exe has stopped working" window that pops up in the release version in case of errors. I just want the program to terminate (maybe also give an error message, but not necessarily) and not have it remain blocked waiting for someone to click the "Close the program" button. I have to mention that I have 64 bit Windows 7 Professional on my machine.
I have read about several things, such as:
the _set_abort_behavior function. This solves the case when abort() is called, but that is not the case for errors like "vector subscript out of range".
I know I could be solving some of these errors by doing exception handling, but not all errors are exceptions, therefore this would not solve my entire problem.
I've also read something about the Dr. Watson debugger, which is supposed to terminate the application silently, but I have the impression that this debugger is not available for Windows 7. Plus I don't know if this debugger would solve my problem in the release mode...
I don't find that disabling Error Reporting on my entire machine is an elegant option, although I read that this could also be an alternative (not really one that I want to take).
How can I do this in Visual Studio? Are there any settings I could use?
Is there maybe a way to turn all errors in exceptions in Visual Studio, so that I can solve the problem with the exception handling mechanism? (please be tolerant if this was a stupid question)
I'm looking forward to your proposals. Many thanks for your time!
Best regards,
Cornelia
You can use
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
MSDN documentation for SetErrorMode
You can also refer here
Hope this will solve your problem...
A good way is to add your own unhandled exception filter (see SetUnhandledExceptionFilter() docs) and then write a log and a mini dump so that you can do whatever error handling you need to (eg close devices/handles) and you also have a crash dump that you can analyse later. Useful information in this answer: https://stackoverflow.com/a/1547251/188414
Sometimes this error occurs only because you have not added a & sign before the value you have used in scanf
Try the following which solved my problem
From
scanf("%d",code);
To
scanf("%d",&code);

Strange runtime error, seemly microsoft related

I am using the debug_new tool that come in the pack of tools NVWA made by Wu Yongwei. http://wyw.dcweb.cn/
I turned it off once to track a heisenbug, that now is fixed. But as I turned it on, my program throws a bizarre error:
It loads, but before accepting any input it quits and writes on the console:
"This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information
Process returned 3 (0x3) execution time : 0.828s"
How I debug that? I have no idea what on the code is throwing the error (since when using a debugger it still quits the same way, and the debugger reports no errors with exit of the debugger being 0)
EDIT for those that don't read tags: I am using C++, compiling with MingW on Windows.
If you're running under the Visual Studio debugger, go to the Debug/Exceptions menu and check the box for the "C++ Exceptions" item - this will cause the debugger to break whenever an exception is thrown.
You might need to fiddle with the various sub-options (std:exception, void, etc) for the exception types if your code throws a lot of exceptions that it catches and you're not interested in breaking into the debugger when they get thrown.
KB884538 -- try installing the hotfix.

How to debug a Visual C++ Runtime Error

I am writing a C++ COM object in Visual Studio 2008 that is an Internet Explorer Browser Helper Object. Recently, when running in IE, IE has started frequently popping up a dialog titled "Microsoft Visual C++ Runtime Library" with an error message "Runtime Error!" and going on to say that "The application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." Unlike usual, this dialog only has an OK button but no debug button, so IE then terminates and I'm not left with so much as a stack trace or even a hint of what part of my code could have been so buggy. I'm not sure where in my code it is crashing.
How does one troubleshoot a "Runtime error" problem? What are possible causes of a runtime error? (memory related bugs perhaps?) What sort of problems should I be checking my code for to attempt to eliminate this sort of crash? I need some ideas on how to troubleshoot this one, its a bit elusive.
When you see that dialog, start VS2008 with your COM object project.
Then use the menu Debug->Attach to process to attach the debugger to the IE process which has your COM object loaded.
Then break into the process (Debug->break all) and you get the stack trace.
It bombs due to an unhandled exception. That gives you a chance to make the debugger stop on the first chance exception, right at the point where it is raised. Open your project, make iexplorer.exe the startup program. Debug + Exceptions, check the Thrown flag on the unmanaged exceptions. Make it crash to get the breakpoint.