How to reactivate Windows Error Reporting for my application (cpp)? (Windows 10) - windows-error-reporting

TLDR
When one of my applications executes _CrtDbgBreak() it just writes a .dmp file and exits. On any other application _CrtDbgBreak() causes the app.exe has stopped working -dialog where I can chose to break into my debugger (VS 2013).
This is my desired behavior.
Background
A few weeks ago I experimented with Windows Error Reporting to find out if/how the WER Dialog could be suppressed. Apparently I succeeded for my application and unfortunately I haven't found the way how to undo this.
In the meantime I have had to deal with a number of other things so that I no longer remember which steps I exactly took at the time. (Should have taken notes, I know.) Since it works for other applications, I am guessing a setting specific to my app needs to be reset.
I turned to the usual suspects on my machine but so far I haven't found anything:
HKCU\Software\Microsoft\Windows\Windows Error Reporting
HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting
Policy Editor: Computer Configuration\Administrative Templates\Windows Components\Windows Error Reporting
Policy Editor: User Configuration\Administrative Templates\Windows Components\Windows Error Reporting
WER Service is running
I have even removed all occurrences of my executable's name from my entire registry but this hasn't made any difference. What else am I missing?

One possible reason is your app/exe is added to the WER's exclusion list. See 'ExcludedApplications' at https://learn.microsoft.com/en-us/windows/desktop/wer/wer-settings.
https://learn.microsoft.com/en-us/windows/desktop/api/Werapi/nf-werapi-weraddexcludedapplication
Check registry at: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\ExcludedApplications
If your app/exe name is found there, remove it.

Maybe you'd set the process error mode, like so
SetErrorMode(SEM_NOGPFAULTERRORBOX);
(see https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode)
[yes - the question is dated, but it's not marked as answered, and this alternative solution may help future readers]

Related

Debugger popup message "Getting DataTip text"

This Debugger message pops up randomly while i am attempting to examine a variable while a breakpoint has hit in Visual Studio 2017.
Shortly thereafter, a larger message box appears that shows the following: "Evaluating the function 'System.Reflection.Assembly.LoadForm' timed out."
After enabling option Tools / Options / Debugging / General / Only managed code, the second message box have disappeared. But first message is still showing.
The problem is that first popup window appears for a relatively long time, that makes debugging process very noncomfortable. What else Visual Studio debugger options could I set to disable this popup?
(1)Tools->Options, uncheck the setting Debugging / General / Enable property evaluation and other implicit function call, and enable the Use Managed Compatibility Mode.
(2)Deleted all the .suo/obj/Bin/.user files in your project, and then re-open your project, clean and build your solution, debug it again.
This solution works fine for me:
Uncheck the new langage JavasScript Language Service in Options -> Editor -> JavaScript -> Language Service.
Option capture
I'm having this same issue and there doesn't appear to be a solution. It's extremely frustrating because when the "Getting DataTip text..." does popup and eventually goes away, my breakpoints no longer work.
The solutions listed here have not solved the problem, I've tried them ALL ... even a wipe and re-install of OS and VS 2015.
Debugging without ability to do property evaluation and other implicit function calls is basically NOT debugging and defeats the purpose.
Microsoft seem to be aware of the problem but keep closing the tickets as "unable to replicate" ... yet, a simple Google Search will show many many thousands of hits of developers running into this problem. I keep opening tickets with Microsoft, but they just keep getting closed or merged with no solution.
Cheers, Rob.
The ONLY solution that worked for me:
CMD window (Run As Admin)
type SFC /SCANNOW and wait for it to complete and hopefully fix any errors
Reboot
Bring up VS 2015 or 2017 without loading any project
In VS select Tools | Import and Export Settings | Reset all Setting ... now pick the template you use (i.e. VB, C, Web)
Exit VS
Load VS project and debug
Cheers, Rob.
Old post, but maybe it will help someone anyway ;)
In my case I got this every time I examined the first variable while debugging.
Annoying as hell as I due to the nature of the work restart the debugger often.
This was cause by that the location where my Visual Studio 2017 files were saved, was a cloud drive and it actually had to sync the files before showing the data.
The solution was to mark that whole folder "Always keep on this device".
Cheers,
​Here is one possible solution:
I had this error never seen - then my graphics card (Nvidia) was gone and I removed the graphics card and worked with the integrated Intel. Then I got this error in after 3-4 steps. I installed a Nvidia again and now the "getting data" text message was never shown again.
Btw: this was the fix for the error
"64 bit debugging operation is taking longer than expected"
I had the same issue when I wanted to evaluate variables while debugging in my Unit tests and couldn't find any solution.
This is the solution that helped me: Tools -> Options / Debugging / General. Uncheck "Call string-conversion function on objects in variables windows".
This might only work for some people.

Chromium-browser build fatal errors in module_list.cc: Check Failed

I've been trying to build chromium on Windows 10, but I am getting weird errors on runtime, which appear to be caused by that pattern:
void CheckFreeLibrary(HMODULE module) {
BOOL result = ::FreeLibrary(module);
DCHECK(result);
}
The first errors are displayed after a few seconds after Chromium is started. Here's what it says:
[5904:9192:0726/025753:FATAL:module_list.cc(18)] Check failed: result.
Backtrace:
base:debug:StackTrace:StackTrace [0x0000....] (e:\projects\clones\chromium\src\base\debug\stack_trace.cc) ...
Since I couldn't copy paste the whole stack, I will join a screenshot of what it all feels like:
I am successful in building the last revision, or at least, it appears to be successful since no errors are showing up when compiling with the toolchain recommended in Building instructions.
Luckily, the first errors aren't modal and it is possible to browse a little bit afterwards. Then, if I put the application into heavy loading (such as Facebook newsfeed), it will suddently stop responding in a silent way. Mouse hovering effects will not show anymore and reloading the page will result in infinite loading. This behavior is also reproductible when right-clicking on some pages (e.g.: google's home page does it sometimes).
What could be an explanation of this not working "out of the box" with default configuration? How to fix this?
P.S.: This question is complementary to this question:
Windows chromium-browser fresh build stacktrace and anonymous fatal errors on runtime, if it can help getting the big picture of the question.
P.S.2.: I am currently trying to rebuild from start again with this slight change to see if it works out better. I will be able to see it after about 10 hours, though (yes, the build is painful on my current setup).
void CheckFreeLibrary(HMODULE module) {
BOOL result = ::FreeLibrary(module);
if (!result) {
result = ::UnmapViewOfFile(module);
}
DCHECK(result);
}
Update - 2016/07/29
Test with CheckFreeLibrary still failed in debug, but I finally found a way to resolve the issues in a build. See update 3 in superuser question. What I did was configuring the build into release mode via gn args. This is, obviously, almost impossible to debug with, so a solution / explanation is yet to be found about why it fails in debug mode. This is quite close now, though.
Update 2 - 2016/08/13
Started all over again to have a debug version again with the latest version in the repositories, and this time I was sure enough to find something. In fact, after I've run through the usual procedure to update, generate and build, I noticed that some win-core-* DLL libraries located in the Windows Kit debugger weren't copied src folder but one of those was assumed to be there during the link process. As a precaution, I've simply copied them all to be sure that any delay-load or build dependency was there. The first time chromium has launched, the errors didn't show up and thought it was resolving the issue. However, right-clicking on the Google Homepage had the same effect (no response, then browser not showing pages anymore). After closing and reopening it, errors are beginning to show up.
Is there anyone that had experienced that? I would be very happy with something like "do it on linux, it works better on this platform". I am not willing to do it without knowing it will work any better, though.
So
BOOL result = ::FreeLibrary(module);
fails in debug builds see if you have a
DWORD WINAPI GetLastError(void);
to get the real error.
I could guess
module not loaded
module is NULL
Perhaps some DEBUG statement is changing the value of module?

Bizarre behavior with Visual Studio's debugger; "The network location cannot be reached" (ERROR_NETWORK_UNREACHABLE)

I've experienced this with every version of Visual Studio starting from 2012 (2012, 2013, 2015 Preview), on multiple computers and multiple projects, but I haven't figured out how to fix it:
Whenever I'm debugging a 64-bit(?) C++ console program, after a few minutes and seemingly completely randomly (when I'm not clicking or typing anything), the console window for the program spontaneously closes and I can no longer debug or step through the program with Visual Studio. When I press Stop and attempt to restart debugging, I usually get ERROR_NETWORK_UNREACHABLE:
// MessageId: ERROR_NETWORK_UNREACHABLE
// MessageText:
// The network location cannot be reached. For information about network troubleshooting, see Windows Help.
#define ERROR_NETWORK_UNREACHABLE 1231L
If I try to attach to the process manually I get the error:
Unable to attach to the process.
The only fix I've found for this is to restart Visual Studio. I can't find any other way to fix it, and I've tried running Process Monitor but haven't found anything.
What causes this problem and how can I fix it?
(?) Upon further checking it seems that this only happens in 64-bit mode, but I'm not 100% sure.
Ok, this is just so wrong
I also have issues with this bug, and in my case it occurred every other debug session. Which meant debug -> stop -> debug -> bug -> restart visual studio -> go to start (repeat every minute during the whole day).
Needless to say I was driven to find a solution. So yesterday I tried procmon, spend hours looking at API monitor differences, looked at plugins, netstat, etc, etc, etc. And found nothing. I gave up.
Today
Until today.
To track down a stupid bug in my program today, I launched appverifier. For my application, I ran the 'basics' tests and clicked save. After a few hours this led me to the bug in my program, which was something like this (extremely simplified version):
void* dst = _aligned_malloc(4096, 32);
memcpy(dst, src, 8192);
Obviously this is a bug and obviously it needed fixing. I noticed the error after putting a breakpoint on the memcpy line, which was not executed.
After a stop and 'debug' again I was surprised to find that I could actually debug the program for the second time. And now, several hours later, this annoying bug here hasn't re-emerged.
So what appears to be going on
So... apparently data from my program is bleeding through into the data or execution space of the debugger, which in turn appears to generate the bug.
I see you thinking: No, this shouldn't happen... you're right; but apparently it does.
So how to fix it? Basically fixing your program (more particular: heap corruption issues) seems to make the VS debugger bug go away. Using appverifier.exe (It's in Debugging tools for Windows) will give you a head start.
Why this works
Since VS2012, VC++ uses a different way to manage the heap. Hans Passant explains it here: Does msvcrt uses a different heap for allocations since (vs2012/2010/2013) .
What basically happens is that heap corruption will break your debugger. The AppVerifier basic settings will ensure that a breakpoint is triggered just before the application does something to corrupt the heap.
So, what happens now is that before the process will break the heap, a breakpoint will trigger instead, which usually means you will terminate the process. The net effect is that the heap will still be in-tact before you terminate your program, which means that your debugger will still function.
"Test"
Before using appverifier -- bug triggered every 2 minutes
While using appverifier -- VS debugger has been stable for 5 days (and counting)
This is an environmental problem of course. Always hard to troubleshoot, SysInternals' utilities like Process Monitor and Process Explorer are your primary weapons of choice. Some non-intuitive ways that a network error can be generated while debugging:
Starting with VS2012, the C runtime library had a pretty drastic modification that can cause very hard to diagnose mis-behavior if your program corrupts the heap. Much like #atlaste describes. Since time memorial, the CRT always created its own heap, underlying call was HeapCreate(). No more, it now uses GetProcessHeap(). This is very convenient, much easier now to deal with DLLs that were built with /MT. But with a pretty sharp edge, you can now easily corrupt the memory owned by Microsoft code. Not strongly indicated if you can't reattach a 64-bit program, you'd have to kill msvsmon.exe to clear up the corruption.
The Microsoft Symbol Server supplies PDBs for Microsoft executables. They normally have their source+line-number info stripped, but not all of them. Notably not for the CRT for example. Those PDBs were built on a build server owned by DevDiv in Redmond that had the source code on the F: drive. A few around that were built from the E: drive, Patterns+Practices uses that (unlikely in a C++ program). Your debugger will go look there to try to find source code. That usually ends well, it gives up quickly, but not if your machine uses those drive letters as well. Diagnose by clearing the symbol cache and disabling the symbol server with Tools + Options, Debugging, Symbols.
The winapi suffers from two nasty viral infections it inherited from another OS that add global state to any process. The PATH environmental variable and the default working directory. Use Control Panel + System + Advanced + Environment to have a look at PATH, copy/paste the content of the intentionally small textboxes into a text editor. Make sure it is squeaky clean, some paralysis at the usual mess is normal btw. Take no prisoners. Having trouble with the default directory is much harder to troubleshoot. Both should pop out when you use Process Monitor.
No slamdunk explanations, it is a tough problem, but dark corners you can look in.
I have the same problem. Thought it was related to 64 bit console apps, where it is very easily triggered with almost any debug session. But, it also happens on 64 bit windows apps too. Now I am seeing it on 32 bit windows apps. I am running Windows 8.1 pro on a single desktop with the latest version of vs 2013 and no remote debugging. My (added) extensions are Visual Assist, Advanced Installer, ClangFormat, Code Alignment, Code Compare, Duplicate Selection, Productivity Power Tools 2013, and Visual SVN.
I discovered that the "Visual Studio 2013\Settings\CurrentSettings.vssettings" file gets corrupted. You can delete this file and recreate it by restarting VS or you can try to edit the XML. I then keep a copy of a good settings file that I use to replace when it gets corrupted again.
In my case, the corrupted line begins with
</ToolsOptionsSubCategory><ToolsOptionsSubCategory name="XAML" RegisteredName="XAML"
... and it is extremely long (I think this is why it is prone to corruption).
I just disabled in the Menu
Tools > Options
Debugging > Edit and Continue
Native-only options > Enable native Edit and Continue
and now it does not give the that stupid error which was preventing the starting of the debuggee application.
I also had the same problem with VS2015. It was so frustrating that a simple Hello World program gave this error when I ran debugger for the second time. Tried uninstall and reinstall and didn't work.
Finally, the solution mentioned in https://social.msdn.microsoft.com/Forums/vstudio/en-US/8dce0952-234f-4c18-a71a-1d614b44f256/visual-studios-2012-cannot-findlaunch-project-exe?forum=vsdebug
worked. Reset all visual studio settings using Tools->Import and Export settings. Now the issue is not occurring.

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);

Why does a MFC application behaves mysteriously in encrypted hard drive environment

I'm working on a bug where I have an MFC application that does weird things when installed in when Sophos Safeguard hard drive encryption is installed. I'm sorry to be so vague here, but I'm writing this away from the office so this is all from my (poor) memory.
Three things I've noticed:
AfxGetResourceHandle() doesn't return a consistent resource handle. There is a single case where we try to load a string resource, and for some reason, the resource handle that we get from this method is different to all the other stings.
Can't construct a CDocumentTemplate. There is a trace error which I cant seem to recall. Will edit and post when I'm in tomorrow.
This behaviour appears to manifest in a Visual Studio 2005 version of the project, but not a Visual Studio 2008 version. Unfortunately moving to the 2008 version is not an option.
The bug is not always reproducable if I step through with a debugger. Also, bringing up debug message boxes changes the behaviuor, which leads me to think that either there is some kind of race condition going on with the way MFC events are being handled, but I'm not sure how I'll ever know for sure, or even what I can do about it if I did.
I think there's some underlying reason that the app is behaving weirdly, but what I've posted are more symptoms. Can anyone think of what I should check for?
I've run Windows update on the test environment to ensure everything was up to date, and I've examined the process in procmon to see if the disk encryption stuff was getting in the way and conflicting with files - it didn't appear to be, but it does appear to be involved in some way as our app accesses Sophos related paths in the temp directory.
If your code is multithreaded (which I assume it is, since you mentioned the possibility of a race condition), then the likelihood is that the decryption delays are exposing concurrency flaws. You might want to try running the application off of a network share or similar slow access device to see if it manifests similar problems.
Turned out that the antivirus software was injecting itself in a way where the antivirus' software's resource handles were overridng the app's resource handles. Yuck!