crashdump debugging with Visual Studio 2010 - c#

I am trying to get crash dump debugging working with 2010, but it keeps failing.
I get this error when I try to start debugging:
"Managed Minidump Debugging: The signature verification for the file 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscordbi.dll' failed with the error 0x800700c1.:
I'm using the simplest program I can think of just to get off the ground (below).
Here are the steps I am taking:
Build
Run with a double-click from Windows explorer
right-click on the process in TaskManager, and select "Create Dump File"
kill the process
open the dump file in Visual Studio (File | Open, set filter to crash dumps)
Select "Debug with Mixed"
much loading of symbols (I have MS Symbol server enabled)
Boom (I get an error dialog saying I need to specify my symbol path -- which I believe I have done -- MS symbol server is enabled, and my solution is loaded)
In the output window, I get the following error (note that there are also a bunch of successful symbol loads, including for my exe):
Managed Minidump Debugging: The signature verification for the file 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscordbi.dll' failed with the error 0x800700c1.
(All the while, the solution with the code for my exe is loaded in the Visual Studio instance).
Any idea what I am doing wrong? Is this the right procedure for crashdump debugging in VS 2010?
The test dummy program:
class Program
{
public static string AStaticProperty = "Hello World";
static void Main(string[] args)
{
DoLoop(10000);
}
static void DoLoop(int iterations)
{
for (int i = 0; i < iterations; i--)
System.Threading.Thread.Sleep(500);
}
}
Edit
I'm going to vote to close -- I don't know exactly what the deal is, but everything is working now.
Here's what I did:
I started debugging the running process in VS 2010
I used the "save dump file" option off of the debug menu in 2010
I stopped the process and loaded the dump file.
It worked, so I thought "hmm, maybe the problem was with the dump file that I created (had used both adplus and TaskManager).
But no, now those work too. (although they failed very reliably until I did the 3 steps above). Weird, but now I cannot repro, so I'm going to vote to close.

Maybe this question/answers "Symbol issue when debugging C# code" helps you out.

The common tool used to debug dumps is WinDbg which is available in Debugging Tools for Windows. For x64 dumps you need the x64 debugger, while for x86 you need x86 debugger.
Visual Studio is x86 only, so you should not expect it can debug all dumps.

I think that this was an unstable machine/need a reboot issue. I have been unable to repro the problem

Related

R.NET works with x86 but not x64

I'm trying to build and run the Hello World sample at the tutorial page at R.NET. When I force the program to run in x86 mode, it seems to do OK. However, when I run in x64, it stops very early on with the message, "[program] exited with code-1073740791"
I've installed the latest version of R at The R Project and have ran the troubleshooting steps. The output I've gotten from the troubleshooting program is:
Is this process 64 bits? True
Info: caller provided rPath=null, rHome=null Info: R.NET looked for preset R_HOME env. var. Found null
Info: Found Windows registry key RDotNet.NativeLibrary.WindowsRegistryKey
Info: Found Windows registry key RDotNet.NativeLibrary.WindowsRegistryKey
Info: Found sub-key InstallPath under RDotNet.NativeLibrary.WindowsRegistryKey
Info: InstallPath value of key RDotNet.NativeLibrary.WindowsRegistryKey: C:\Program Files\R\R-4.0.3
Info: R.NET looked for platform-specific way (e.g. win registry). Found C:\Program Files\R\R-4.0.3
Info: R.NET trying to find rPath based on rHome; Deduced C:\Program Files\R\R-4.0.3\bin\x64
C:...\bin\x64\Debug\net5.0\ConsoleNet5R.exe
(process 33500) exited with code -1073740791.
I have verified that there IS a file R.dll where it deduced it should be, "C:\Program Files\R\R-4.0.3\bin\x64". When I step through using my decompiler, it appears that it gets choked up at what is showing up for me as line 400 in REngine.cs, under the function "Initialize" at this.GetFunction<setup_Rmainloop>()(); It doesn't appear to throw an exception, it just stops. I'll be honest--I'm not sure what this line is supposed to be doing...
Any ideas what is going on? I can run in x86 mode if I have to, but I would like to use x64 if possible.
This issue has been reported for a while..
I experienced the same with R-4.0.3 to R-4.0.5.
There is not such issue for R-4.0.2 and former versions (4.0.1, 4.0.0, 3.6, 3.5)
I've done an analysis of this and tracked findings in one of the RDotNet GitHub issues where this was raised (https://github.com/rdotnet/rdotnet/issues/139#issuecomment-898699993).
This appears to be related to the Control Flow Guard security feature enabled in Windows 10. This doesn't happen in the R programs themselves because they are compiled using a different compiler (gcc via mingw) than Microsoft's. However, the CFG feature is enabled for .NET binaries and there is something (sorry, I don't know the actual underlying root cause) in a change within R 4.0.3 in setjmp/longjmp calls that is causing the crash (see: https://github.com/wch/r-source/blob/trunk/src/gnuwin32/fixed/h/psignal.h#L44-L51).
Although you would actually be disabling a security feature, I have had some luck for now in modifying my program after it is compiled (you can set this as a post-build event). You will need to run something like: link /EDIT /GUARD:NO <yourapp>.exe, which disables CFG.
Thanks to https://github.com/dotnet/runtime/issues/11899#issuecomment-502195325 for providing the instructions needed for this workaround, and https://www.trendmicro.com/en_us/research/16/j/control-flow-guard-improvements-windows-10-anniversary-update.html for providing the amazing analysis of CFG that led to an understanding of what was going on.

Inspect dump files from UWP app

First I enabled saving of dump files on a Windows 10 Mobile phone:
Settings > Update & Security > For developers > Save this many crash dumps: 3
Then I debugged an app which throwed an exception. I continued the debugging after stop. After disconnecting and connecting the mobile phone again, I was able to access the dump file stored under Windows phone\Phone\Documents\Debug directory. The file is called
FPCL.WIndows - a736c773-c105-4b30-a799-4bf317872f5e with exception C000027B on 5-03-2016 12.11.dmp
and has about 140 MB!
I copied the file to the bin directory of my UWP app. Afterwards I opened it as file in Visual Studio 2015 (in the same project). Now I can see the Dump Summary and I have the following buttons:
Debug with Managed Only
Debug with Mixed
Debug with Native Only
Set symbol paths
Copy all to clipboard
If I run Debug with Managed Only I get
A fatal exception was caught by the runtime. See $stowedexception in the Watch window to view the original exception information.
and on clicking Break I get
No compatible code running. The selected debug engine does not support any code executing on the current thread (e.g. only native runtime code is executing).
In the Watch 1 window I see the following
Name: {CLR}$stowedexception
Value: {"The method or operation is not implemented."}
Type: System.NotImplementedException
This should be the exception I have thrown in my app. When I open this node and look under StackTrace I can get a line number. On pressing Continue I get
The debugger cannot continue running the process. This operation is not supported when debugging dump files.
So I can only stop it.
If I run Debug with Mixed I get again
A fatal exception was caught by the runtime. See $stowedexception in the Watch window to view the original exception information.
and on clicking Break I get
kernelbase.pdb not loaded
kernelbase.pdb contains the debug information required to find the source for the module KERNELBASE.dll
Module Information: Version: 10.0.10586.218 (th2_release.160401-1800) Original Location: KERNELBASE.dll
Try one of the following options: Change existing PDB and binary search paths and retry: Microsoft Symbol Servers
Here I can either press Load or New. So the kernelbase.pdb isn't found under the given location. Should it exists? Where should I find it?
In the Watch 1 window I see the same as above and I can only stop it.
If I run Debug with Native Only I get
Unhandled exception at 0x76ECDF95 (combase.dll) in FPCL.WIndows - f736c883-f105-4d30-a719-4bf328872f5e with exception C000027B on 5-03-2016 12.11.dmp: 0xC000027B: Anwendungsinterne Ausnahme (parameters: 0x075C6838, 0x00000002).
and on clicking Break I get the same missing kernelbase error as above, but here in the Watch 1 window the Value is Unable to evaluate the expression. So I can only stop it.
According to this post I should be able to inspect the source code and find the cause. But how is such a UWP dump file inspected correctly?
You mention
[...] 0xC000027B [...]
[...] $stowedexception [...]
which are both indicators that there is a Stowed Exception inside the dump.
To analyze such exceptions, first watch Channel 9 Defrag Tools, episode 136 where Andrew Richards explains and then analyzes them (at 3:28).
Then download the PDE extension from the Defrag Tools OnDrive and analyze your dump in windbg instead of Visual Studio.
Regarding the symbols of kernelbase, they should be downloaded from the Microsoft symbol server. To set that up in WinDbg, use .symfix;.reload. If you want to give it another try in Visual Studio, go to Debug / Options and choose Debugging / Symbols, then check "Microsoft Symbol Servers".
Regarding the button to press in Visual Studio, choose "Managed only" when debugging the debug build, because your app will run on CoreCLR and choose "Native Only" when debugging the release build, because your app will use .NET native runtime support. (This applies if you didn't change the default settings; otherwise choose according to your compilation settings)

Unable to run Console Application from Visual Studio: System.AccessViolationException

Description
When launching any Console Application, the code stops running immediately on an AccessViolationException (Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt). More info included in the next section.
Technical Symptoms
The Call Stack only contains external code:
Exception:Thrown: "The message filter indicated that the application is busy. >(Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))" (System.Runtime.InteropServices.COMException)
A System.Runtime.InteropServices.COMException was thrown: "The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))"
Time: 12/10/2015 10:59:55 AM
Thread:vshost.NotifyLoad[15344]
I created a new Console Application, containing only Console.WriteLine("Hello world!");
Running the new Hello world app results in the same exception and an identical
call stack.
Background
I suspect this has nothing to do with the issue, as I will explain, but I feel it is important to answer the obvious question, "what were you doing when the issue happend?" The last change I made was adding an extension to my Selenium Driver to hotkey logout from an application:
public static void logout(this IWebDriver Driver)
{
Driver.FindElement(By.TagName("body")).Click();
new Actions(Driver)
.SendKeys(Keys.Control + Keys.Shift + "x")
.Perform();
}
I also made a change in my App.Config file for one of my projects, but reverting this had no impact either.
Removing this code (the Driver extension and/or the App.Config change) does not resolve this issue. Retrieving a previous check-in does not resolve the issue. I am the only person currently working on this solution.
Discoveries
As mentioned, this is happening for an empty Console Application. Windows Form Applications launch fine. Unit Test Projects launch fine as well.
Research
I've spent hours looking into this. It seems like every similar issue I have looked into is pertinent to debugging only or a .NET version. For me, the issue occurs with a Release as well. Additionally, I have been using .NET 4.5 without any issues or changes on that front. I can't find any articles that seem worth posting, but I might be overlooking something.
Visual Studio Info
Microsoft Visual Studio Ultimate 2013
Version 12.0.30501.00 Update 2
.NET Version 4.6.00081 (just noticed it says 4.5 in my project properties, though)
Running as Administrator
Feedback
When Running from devenv.exe /SafeMode, Visual Studio loaded with:
An exception was encountered while constructing the content of this frame. This information is also logged in "C:\Users\UserName\AppData\Roaming\Microsoft\VisualStudio\12.0\ActivityLog.xml".
Exception details:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at Microsoft.VisualStudio.Shell.Interop.IVsShell5.LoadPackageWithContext(Guid& packageGuid, Int32 reason, Guid& context)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.GetPackage()
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConstructContent()
Additionally, when trying to run, I get an error message of "Error while trying to run project: Invalid Pointer" (again, VS in devenv.exe /SafeMode - see how to run visual studio without plugin and all third party feature if unfamiliar)
Please let me know if I can provide any additional information.
It may be because when you name the project you can't put spaces, I put them and it gave me a AccessViolationException aswell, try using capitals to separate your words, but only use letters and no spaces to be sure.
I also faced this issue with Visual Studio 2010. More interestingly I had several projects in my solution (Console application, WPF application, Windows Forms application) but it was failing only when, I was setting the project which was of type "Console Application" as start up project. Following change finally helped me nail down the issue: Go to project properties of the console application project -> Go to "Debug" tab -> Go to "Enable Debuggers" section in right pane -> Check the "Enable unmanaged code debugging" check box as shown in the snapshot below. Root cause of why it happened is still not known to me. Only thing which I observed as fishy was that there were lot of windows updates which had got installed on my machine the previous night which mostly constituted of office updates and OS updates (More than a dozen KB articles).

Programs randomly getting System.AccessViolationException

Okay so I have been having a lot of issues with debugging. I'm using VS2013 Pro and Windows 8.1. Both are up to date. The issue is, when I start debugging, half the time it throws this error:
An unhandled exception of type 'System.AccessViolationException'
occurred in System.Windows.Forms.dll
Additional information: Attempted to read or write protected memory.
This is often an indication that other memory is corrupt.
Its not my code's fault either. I made a simple test as an example below. Note that I am not referencing System.Windows.Forms from this app.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
List<int> testing = new List<int>();
for(int i =0; i < 50; i++)
{
testing.Add(i);
}
for (int i = 0; i < 50; i++)
{
Console.WriteLine(testing[i].ToString());
}
Console.ReadLine();
}
}
}
I have no idea what's causing this. It will work if I click okay and run it again, most the time. Occasionally I have to do it twice.
Any ideas?
Stack trace:
Changing the Platform Target to x86 works for me, It came to a point that stepping through the code was impossible without the forementioned Exception. I run Win 8.1 64-bit and Visual Studio 2013.
I also ran into this problem on windows10 using visual studio express2015. building to x86 did not fix my problem but the following workaround did the trick:
This issue is caused by the code which gathers return values. It is possible to work around the issue by disabling Managed return values.
Go to the System properties (Win8: WinKey+X, select ‘System’, Win7: Open ‘Properties’ from my computer)
Advanced System Settings
Environment Variables…
Click ‘New’ and add
Name: VSDebug_DisableManagedReturnValue
Value: 1
source: https://connect.microsoft.com/VisualStudio/feedback/details/819552/visual-studio-debugger-throws-accessviolationexception
http://veriworld.verivox.ads/docs/DOC-6011?et=watches.email.document_comment#comment-4629
Seems that in some cases VS/.net framework has memory trampling issues. I really wish people would stop saying 'it cant be' when someone says something breaks.
There is nothing that looks like it may cause issues.
Did you try enabling breaking on exception? This will cause your code to pause when it encounter an exception.
I can confirm this problem. It occurs in a small (very trivial) WinForms program distributed with my own commercial app. It's never happened in any earlier version of VS going back to VS2005, including those run on the same machine. It only occurs in VS2013. My version of VS has no 3rd-party add-ins other than what's installed with VS itself. Problem occurs even when all code in "Main()" is commented out. I've tried rebooting, disabling virus checker, firewall, etc. Makes no difference which version of .NET my app targets either (2.0, 3.5, 4.0, whatever). It happens frequently but randomly. Sometimes it works, sometimes it doesn't. Go figure.
In my case, such VS behavior was caused by Comodo Firewall.
The solution is adding VS Projects folder to Comodo HIPS exclusions list (even if the HIPS is turned off!).
Here is a related thread Comodo forum: https://forums.comodo.com/empty-t98149.0.html

Exception while debugging Shims, UnitTestIsolationException

While using Shims, I get an exception while debugging. While others have reported this issue, none of the fixes that I have found have helped. This is the scenario. Although I discovered this on a full size project, I can reproduce it on a simple project. I only get this exception when using my work computer. If I try it on a coworkers computer or my home computer, I do not get the error.
Windows 7, fully patched.
VS Ultimate 2012, Update 4.
Default Processor Architecture of x64.
No Typemock or other mocking framework installed (that I am aware of).
No run settings or test settings in the solution (have verified in explorer).
[TestMethod]
public void TestMethod1()
{
using (ShimsContext.Create())
{
}
}
If I run the test normally, no issue. However if I try to debug I get the exception on the using statement.
Exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException was unhandled by user code
HResult=-2146233088
Message=UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test
Source=Microsoft.QualityTools.Testing.Fakes
StackTrace:
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext()
at Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()
at MyLogTest.UnitTest1.TestMethod1() in c:\Users\XXXX\Documents\Visual Studio 2012\Projects\MyLogTest\MyLogTest\UnitTest1.cs:line 13
InnerException:
(** user id XXXX'd out for security **).
If I take that failing project from my work computer and put it on my home computer (also VS Ultimate 2012, update 4, Windows 7) I do not get the error while debugging.
I tried doing a full uninstall of VS (including renaming the old VS folder in Program Files) and a fresh install, I still get the exception.
In desperation I turned on logging for Visual Studio. The only significant difference that I noticed was the following in the log for devenv.TpTrace.log
Diagnostic: RockSteady initialized with the following extensions:
Diagnostic: Processing Queue .....
Diagnostic: Operation Dequeue : 'LoadPlaylistOperation'
Diagnostic: Operation left in the the queue: 1
Diagnostic: 'RunWithDebugFromContextOperation', hashcode:12788809
Diagnostic:
I tried looking for that "RockSteady" to see where it was coming from or what it is with no luck. These lines do not appear on my home computer when I perform the same test. I am thinking that there might be something installed on my machine from an SDK or something else that is causing an issue. I don't know that those lines above are the source of the problem, it is just the only major difference I am seeing.
I've been stuck on this for several days now. Any help is appreciated.

Categories