vstest crashed when running some particular tests - c#

When I let run all tests (ca. 800 tests) in my solution, after some time a popup window with error is shown that vstest.executionengine.x86.exe has stopped working.
Some Examples of problem details, that I get are here:
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: vstest.executionengine.x86.exe
Problem Signature 02: 14.0.23107.0
Problem Signature 03: 559b7b6c
Problem Signature 04: mscorlib
Problem Signature 05: 4.6.1076.0
Problem Signature 06: 56d79fa2
Problem Signature 07: 0
Problem Signature 08: ffffffff
Problem Signature 09: System.StackOverflowException
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1051
Additional Information 1: 5cd2
Additional Information 2: 5cd2742c12da7dd4b1d5bf900186a452
Additional Information 3: 2fe2
Additional Information 4: 2fe276cacf1c00cd7a2aed7b27f5a5f9
Problem signature:
Problem Event Name: APPCRASH
Application Name: vstest.executionengine.x86.exe
Application Version: 14.0.23107.0
Application Timestamp: 559b7b6c
Fault Module Name: clr.dll
Fault Module Version: 4.6.1076.0
Fault Module Timestamp: 56d7a0ff
Exception Code: c00000fd
Exception Offset: 00003567
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1051
Additional Information 1: 0127
Additional Information 2: 01273c850b3b6fc6378d3f666887788e
Additional Information 3: 0786
Additional Information 4: 07866ddaac895bff9a7fa791fcdaa4a7
In VS output window I get:
------ Run test started ------
The active Test Run was aborted because the execution process exited unexpectedly. To investigate further, enable local crash dumps either at the machine level or for process vstest.executionengine.x86.exe. Go to more details: http://go.microsoft.com/fwlink/?linkid=232477
========== Run test finished: 0 run (0:03:55,0267906) ==========
When I tried to enable local crash dumps I found out that there is no such registry key so I haven't been able to do it.
I Located all test (22 tests) causing crash of vstest.---.exe, commented them and run all test again and without those "wrong" tests. Everything runs fine.
What can be wrong with those tests? They all are old tests which was working in past. How to locate a problem?

In my experience, StackoverFlowExeptions are very often caused by some recursive method call that never terminates. Try debugging one of those 22 test to find out if recursion is the issue.

There are multiple ways to find the cause of a StackOverflowException in a unit test.
Probably the easiest one is to run one of the 22 tests you've identified under the Visual Studio debugger. For this you select "Debug selected tests" in the context menu of VS Test Explorer. If the exception happens, VS will break and you will be able to look (very) deep into the call stack to find exactly the place where it begins to cycle in a method call loop.
There might be legitimate reasons for this loop (like recursive methods) or there might be a bug. In case of the former it's maybe possible (amongst many other possibilities) that some hierarchical data changed and therefore the unit tests now hit a limit when analyzing the hierarchy recursively.
If you cannot run the unit tests in the VS debugger then you have to get a memory dump of the crashing vstest.executionengine.x86.exe using Windows Task Manager.
For that you first wait until the window of the Windows Error Reporting (WER), that you mentioned in your question, pops up. Then you open Task Manager in the correct bitness - that is 32-bit in your case. That means if you have a 64-bit OS, you have to start C:\Windows\SysWOW64\taskmgr.exe. If you have a 32-bit OS you can run the normal one at C:\Windows\System32\taskmgr.exe.
Then you right click on the vstest.executionengine.x86.exe process and choose "Create Dump File". The resulting .dmp file can be loaded into VS or into WinDbg where the call stacks can be analyzed using the SOS extension.
For debugging a memory dump in VS you can read more about it here.
Regarding WinDbg you have to download it here, set up a few initial configuration settings mentioned here and then list the threads and their call stacks using the commands stated here.
Now you should pretty easily get to the root cause of your problems.

Related

APPCRASH StackOverflowException clr.dll c00000fd

I am running a .Net console application that executes 24 hrs a day. It has a bug that occurs about once every 6 days.
I would like your assistance to fix this bug. First I will provide some background, and then I will provide the exception messaging.
Unfortunately I do not have steps to reproduce. You will see why as you read on.
First some background:
I have robust exception handling in my code (or so I thought). For example I have a try...catch block in my Main() method that captures any unhandled exceptions and if they are FATAL it restarts the underlying task. It works great for any exceptions generated from my own code.
I cannot explain why the below exception isn't handled in my code. My best guess is that clr.dll exceptions do not get caught within the managed stack. And if that is the case, I do not know how to generate a stack trace. I don't even know where to begin to fix this.
The process I am running is using the following versions and modules:
C# .Net Framework 4.6.1
Console App project type
System.Net.WebClient
log4net
Windows 7 64-bit
At the time of the crash I checked RAM and HDD: both have plenty of free space.
About the code I'm executing. The process is a continous loop that downloads data from a website and saves it to a text file. If there is an error, it is logged using log4net.
The basic loop is this:
for (int i = 0; i < 5; i++)
{
try
{
return new WebClient().DownloadString(url);
}
catch
{
Thread.Sleep(500); // slow it down.
}
}
The following is the only message that displays in my console window when the exception occurs: (no stack trace displayed)
Process is terminated due to StackOverflowException
My console application completely freezes up and a dialog window pops up with the following information (closing this dialog also terminates my application)
Problem signature:
Problem Event Name: APPCRASH
Application Name: foo.goo.BatchExecutor.exe
Application Version: 1.0.0.0
Application Timestamp: 5a50f3eb
Fault Module Name: clr.dll
Fault Module Version: 4.7.2117.0
Fault Module Timestamp: 59cf5105
Exception Code: c00000fd
Exception Offset: 0002429f
OS Version: 6.1.7601.2.1.0.256.48
Locale ID: 1033
Additional Information 1: 28e8
Additional Information 2: 28e8aacd8abfe32876bc8363e8e5c526
Additional Information 3: 6916
Additional Information 4: 6916665ca52ff482d854f190abcf46b2
The only other place I could find information about the crash is in the Windows Event Log:
Log Name: Application
Source: Application Error
Date: 1/23/2018 5:51:46 PM
Event ID: 1000
Task Category: (100)
Level: Error
Keywords: Classic
User: N/A
Computer: FOOGOO
Description:
Faulting application name: foo.goo.BatchExecutor.exe, version: 1.0.0.0, time stamp: 0x5a50f3eb
Faulting module name: clr.dll, version: 4.7.2117.0, time stamp: 0x59cf5105
Exception code: 0xc00000fd
Fault offset: 0x0002429f
Faulting process id: 0x1e00
Faulting application start time: 0x01d39169354e41a7
Faulting application path: C:\Users\Owner\Desktop\SHARED\foo.goo.BatchExecutor\foo.goo.BatchExecutor.exe
Faulting module path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Report Id: 21b9b2a4-00a9-11e8-9f6c-94c69110a719
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Application Error" />
<EventID Qualifiers="0">1000</EventID>
<Level>2</Level>
<Task>100</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2018-01-24T01:51:46.000000000Z" />
<EventRecordID>1852</EventRecordID>
<Channel>Application</Channel>
<Computer>FOOGOO</Computer>
<Security />
</System>
<EventData>
<Data>foo.goo.BatchExecutor.exe</Data>
<Data>1.0.0.0</Data>
<Data>5a50f3eb</Data>
<Data>clr.dll</Data>
<Data>4.7.2117.0</Data>
<Data>59cf5105</Data>
<Data>c00000fd</Data>
<Data>0002429f</Data>
<Data>1e00</Data>
<Data>01d39169354e41a7</Data>
<Data>C:\Users\Owner\Desktop\SHARED\foo.goo.BatchExecutor\foo.goo.BatchExecutor.exe</Data>
<Data>C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll</Data>
<Data>21b9b2a4-00a9-11e8-9f6c-94c69110a719</Data>
</EventData>
</Event>
*****UPDATE WITH SOLUTION WORKAROUND *****
I have given up trying to handle this exception within .Net. I found an effective workaround. This workaround applies to Windows, specifically any version with an Event Viewer.
Workaround Instructions.
1) Open control panel->Admin Tools->Event Viewer->Windows Logs->Applications.
2) Select the offending event. In my case, it is state ERROR, and matches the example that you see above.
3) On the right hand side click "Attach Task to This Event".
4) Complete the wizard. In my case, I restart my application.
5) Save the task.
6) Now switch over to Task Scheduler and find the task. Click Properties. Click through the tabs and configure the Task as you see fit.
*****UPDATE WITH SOLUTION WORKAROUND *****
I have given up trying to handle this exception within .Net. I found an effective workaround. This workaround applies to Windows, specifically any version with an Event Viewer.
Workaround Instructions.
1) Open control panel->Admin Tools->Event Viewer->Windows Logs->Applications.
2) Select the offending event. In my case, it is state ERROR, and matches the example that you see above.
3) On the right hand side click "Attach Task to This Event".
4) Complete the wizard. In my case, I restart my application.
5) Save the task.
6) Now switch over to Task Scheduler and find the task. Click Properties. Click through the tabs and configure the Task as you see fit.
I suggests to use ProcDump, it can be configured to generate a crash dump when the StackOverflowException occurs.
procdump -accepteula -e 1 -f C00000FD.STACK_OVERFLOW -g -ma <PID> <OUTPUT PATH>
Then analyze the dump file using one of this tools
Visual studio, windbg, debugdiag, clrmd.
I suggest trying DebugDiag (https://www.microsoft.com/en-us/download/details.aspx?id=49924) to capture the crash and analyse the resulting process dump. Make sure you include pdbs alongside your exe, to make diagnosis easier: in the Project properties, Build tab: set the Configuration to the configuration that you use to build the exe. In the Output section, Advanced button, set the Debugging information to Pdb (or Full).
To help collect a stack trace, PHPTower, you can do what I did and subscribe to the AppDomain.CurrentDomain.UnhandledException event of your program at the beginning of your Main() function
The signature of the event handler looks like the following, allowing you to get the exception, and output a stack trace with the Exception.ToString() method.
private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
File.AppendAllLines(FileName, e.ExceptionObject.ToString());
}
Happy hunting!
-cadatoiva

Buffer Overflow in clr.dll at application start-up

I have two computers. Both work under Windows 7 Embedded and have same version of .Net 4.0 framework installed.
My WinForms application works with no issues on one of them but fails at start-up with BEX in clr.dll on another.
Problem Event Name: BEX
Application Name: Myapplication.exe
Application Timestamp: 5669ec33
Fault Module Name: clr.dll
Fault Module Version: 4.0.30319.526
Fault Module Timestamp: 4eb3b6b1
Exception Offset: 002b65ec
Exception Code: c0000409
Exception Data: 00000000
OS Version: 6.1.7601.2.1.0.320.65
Locale ID: 1033
Additional Information 1: a835
Additional Information 2: a835052745ddb3bce091e0cd181de7e7
Additional Information 3: 7cb8
Additional Information 4: 7cb8eec426d05584b36071af9d74719d
What is very "strange"
I was able to find two things in my application that somehow have impact or provoke this problem.
First I found exact line of code.. I have few buttons that I manually create manually on UI thread. And if I remove next line my application starts.
btn.Font = new Font("Tahoma", 9, FontStyle.Bold, GraphicsUnit.Point, 0);
Second I noticed that if I use my debug logger which uses StackFrame to find out where log message is coming form, Application will crash with the same error in CLR but at some other place. Not at the line I mentioned above.
My two computers have different RAM. 2GB and 1GB. Application fails on the second one with 1GB of memory. But application iself uses 30 MB and system has ~350 MB of free memory. Could memory be a reason ?
My research for the most part referred me to different hot-fixes issued by Microsoft. I tried them but nothing helped. I also tried to install .Net v4.5 but with the same negative result.
Where else I can start looking for the problem ?
... And yes, this problem does not show up when running application with attached debugger.
Update
I just realised that "Exception Code: c0000409" means STATUS_STACK_BUFFER_OVERRUN. This brings some sense to strange application behaviour that I have but still not clear why it works on one computer but does not work on another.
Solution finally found
My application uses third party C# library which is actually a wrapper on top of calls to other native library. I decompiled library and realised that calling convention is set to CallingConvention.Cdecl but as I see from Dependency Walker application, all methods in native library has CallingConvention.StdCall
After changing calling convention and recompiling the library issue disappeared.

Visual C# Command Line Compiler has stopped working?

I have a project iv been working on for sometime, but today when i tried to build the solution the following message was displayed.
This message appears twice when i try run my project, but the project is able to run after this appears.
The problem is i cant publish as this stops my publishing.
The problem signature reads the following:
Problem Event Name: APPCRASH
Application Name: csc.exe
Application Version: 4.0.30319.17929
Application Timestamp: 4ffa73cb
Fault Module Name: bitguard.dll
Fault Module Version: 2.6.1694.246
Fault Module Timestamp: 524a99fc
Exception Code: c0000005 Exception
Offset: 0017966f
OS Version: 6.1.7601.2.1.0.256.1 Locale ID: 7177
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
I have run and build this project many times as well as publish, but this now has become a problem out of the blue.
This is only happening with one project and my other run and build fine.
I have posted a bounty on a similar question as i need this resolved quickly:
Command Line Compiler stops working in specific project
Thanks in advance.
Found the solution with the help of Joe's comment above.
Following the Fault Module name you can see the problem file is bitguard.dll.
http://www.spywareremove.com/file/bitguarddll-367251/
Adw Cleaner is a free malware cleaner that helped me find bitguard and remove it safely.
http://download.cnet.com/AdwCleaner/3000-7786_4-75851221.html
The problem has been solved.

C# windows application Event: CLR20r3 on application start

I created a C# application and installed it on my test box. My app works perfect on my dev box, but when I install in on a different machine it crashes in the Main(). I get the EventType: CLR20r3
here is the Event Message
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: logfileviewer.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 4f356c9c
Problem Signature 04: LogFileViewer
Problem Signature 05: 1.0.0.0
Problem Signature 06: 4f356c9c
Problem Signature 07: 94
Problem Signature 08: 44
Problem Signature 09: System.IO.FileNotFoundException
OS Version: 6.1.7601.2.1.0.256.1
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
I used the details and looked up the error code in IL Disassembler and cam back with the following...
Method #5 (06000094)
-------------------------------------------------------
MethodName: .ctor (06000094)
Flags : [Public] [HideBySig] [ReuseSlot] [SpecialName] [RTSpecialName] [.ctor] (00001886)
RVA : 0x000081d0
ImplFlags : [IL] [Managed] (00000000)
CallCnvntn: [DEFAULT]
hasThis
ReturnType: Void
No arguments.
.NET 4.0 has been uninstalled and re installed on the system and did not change anything. I have searched all over the net and everyone with the same problem do not seem to have a solution. I have now spent a day and a half on this problem. I would hate to miss my deadline do to not being able to launch the application.
This is the only code in my Main()
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain());
}
Here are the details from the Event Viewer
Application: LogFileViewer.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Stack:
at LogFileViewer.frmMain.InitializeComponent()
at LogFileViewer.frmMain..ctor()
at LogFileViewer.Program.Main()
EventData
Application: LogFileViewer.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Stack: at LogFileViewer.frmMain.InitializeComponent() at LogFileViewer.frmMain..ctor() at LogFileViewer.Program.Main()
Not sure how the designer can have a FileNotFound Exception. I am using the DotNetBar.dll and I am referencing it out of the install directory, so that should be good. I can post my designer if you want, but there is quite a bit there.
I've seen this same problem when my application depended on a referenced assembly that was not present on the deployment machine. I'm not sure what you mean by "referencing DotNetBar out of the install directory" - make sure it's set to CopyLocal=true in your project, or exists at the same full path on both your development and production machine.
I encountered the same problem when I built an application on a Windows 7 box that had previously been maintained on an XP machine.
The program ran fine when built for Debug, but failed with this error when built for Release. I found the answer on the project's Properties page. Go to the "Build" tab and try changing the Platform Target from "Any CPU" to "x86".
.NET has two CLRs 2.0 and 4.0. CLR 2.0 works till .NET framework 3.5. CLR 4.0 works from .NET 4.0 onwards. Its possible that your solution is using a different CLR than your reference assemblies. In your local development environment, you might have both the CLRs and hence you did not faced any problem. However when you moved to deployment environments, they might have a single CLR only and you got this error.
Have been fighting this all morning and now have it solved and why it happened. Posting with the hope it helps others
I installed the Krypton.Toolkit which added the tools to the Visual studio toolbox automatically. I then added the tools to the designer, which automatically added the dll to the projrect references, however the toolkit was marked as CopyLocal=false
I built an installer, using all dlls in the release build folder (of course the above dll wasn't there).
Setting copylocal=true, then rebuilding the installer, everything worked fine.
To solve CLR20r3 problem set - Local User Policy \ Computer Configuration \ Windows Settings \ Security Settings \ Local Policies \ Security Options - System cryptography: Use FIPS 140 compliant cryptographic algorithms, including encryption, hashing and signing - Disable

How to troubleshoot error: “Program stopped working APPCRASH”

I have a log and a try catch in this console app, but does not seem to get that far.
Works fine on my dev machine, does not on Win Server 2008. Event viewer has the same info as below.
I understand there's not much to go on here, but that's what I know. All prev deployments worked, so I'm at a loss.
Please don't close, and help me solve this problem. I will answer any questions I can.
Thanks.
Description:
Stopped working
Problem signature:
Problem Event Name: APPCRASH
Application Name: LoaderLive.exe
Application Version: 2.0.1.0
Application Timestamp: 4ef176d6
Fault Module Name: KERNELBASE.dll
Fault Module Version: 6.1.7601.17651
Fault Module Timestamp: 4e211319
Exception Code: e0434f4d
Exception Offset: 0000b9bc
OS Version: 6.1.7601.2.1.0.272.7
Locale ID: 1033
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
If you have a top-level try/catch and it's not catching the exception, it might be because the fault is occurring at a very low level (e.g. somewhere in a native code library), too early (before your Main even starts), or on another thread (where your try/catch can't "reach").
To find out what is going on, run the application under a debugger. If you have Visual Studio installed on the target machine, you can do it from there (open the EXE and "Start Debugging"). If not, you can use windbg.exe / cdb.exe (available as Debugging Tools for Windows in the Windows SDK). Within the debugger, you should be able to see where the fault occurs, as it will by default stop on any fatal exception.

Categories

Resources