Repository navigation
Description
This is forwarded from Stack Overflow. The main question is:
How do I debug a .NET universal app dump in a way that I can see the .NET callstack?, which IMHO results in the question Where can I get SOS for Windows 10 IoT?
Details (in case the question gets deleted there):
I have a dump of a .NET Universal App running on Raspberry Pi 2, Windows 10 IoT:
0:000> vertarget
Windows 10 Version 10240 MP (4 procs) Free ARM (NT) Thumb-2
Product: WinNt, suite: SingleUserTS
Built by: 10.0.10240.16384 (th1.150709-1700)
I see it uses coreclr like Silverlight did before.
0:000> lm vm coreclr
start end module name
6e430000 6e7fd000 coreclr (export symbols) coreclr.dll
Loaded symbol image file: coreclr.dll
...
Timestamp: Thu Jul 16 21:37:39 2015 (55A88693)
...
File version: 4.6.23117.0
Product version: 4.0.23117.0
Doing an !analyze -v does not download SOS automatically.
Loading the Silverlight version of SOS I found on my PC indicates the wrong version:
0:000> .load C:\Program Files\Microsoft Silverlight\5.1.20513.0\sos.dll
0:000> !threads
The version of SOS does not match the version of CLR you are debugging. Please
load the matching version of SOS for the version of CLR you are debugging.
CLR Version: 4.6.23117.0
SOS Version: 5.1.20513.0
Failed to load data access DLL, 0x80004005
...
It seems that SOS was implemented on GitHub but I could not find a binary download.
On my PC with Visual Studio 2015 Community, I could find a file called mrt100sos.dll in the folder C:\Program Files\MSBuild\Microsoft\.NetNative\x86\ which turns out to be a debugging extension and says:
0:000> !help
mrt100sos is a debugger extension DLL designed to aid in debugging .NET Native
programs.
...
which sounded great. But running any commands results in the following error message:
0:000> !threads
Failed to find runtime DLL (mrt100_app.dll), 0x80004005
Extension commands need mrt100_app.dll in order to have something to do.
I'm running out of ideas...
How do I debug a .NET universal app dump in a way that I can see the .NET callstack?, which IMHO results in the question Where can I get SOS for Windows 10 IoT?
Activity
ellismg commentedon Sep 3, 2015
/cc @noahfalk @leculver
sergiy-k commentedon Mar 23, 2016
@tzwlai, @cshung, is this on track for RC2?
cshung commentedon Mar 23, 2016
Hi EveryOtherUsernameWasAlreadyTaken,
We are confused with your description.
From what you are saying your process is running CoreCLR.dll, and mrt100sos.dll is built for .Net native which is useful for debugging processes running in CoreCLR.
Can you please elaborate what you are trying to do?
noahfalk commentedon Mar 24, 2016
UWP apps can be run on two different runtimes, the .Net Native runtime (compiled in advance) and the CoreCLR runtime (jit compiled). Anything you submit through the store will be running with .Net Native. When building from VS using .Net Native is controlled by a checkbox in the build settings, something like "Enable Native compilation". By default this is not checked when building in Debug and checked when building in Release.
Since you said your dump contained coreclr.dll, presumably you compiled this application with Visual Studio in the debug configuration? I haven't tried personally, but as far as I know Visual Studio supports live debugging on a Raspberry Pi 2 so that would be the way I'd expect many developers to get a callstack in the development timeframe. You can also open dump files with Visual Studio using the File->Open->File dialog and select the .dmp file. I tried viewing the callstack in a dump on an app running coreclr just now and it worked fine, though I don't have an exact repro of your setup. Is there any particular reason you wanted to use SOS and not VS? It seems like VS could easily handle your callstack needs, as well as giving you better visualizations of arguments and locals than what SOS typically provides.
I don't recall offhand if we released an SOS binary for CoreCLR as part of the UWP SDK, but I'm hoping @cshung can help run that down : ) If SOS didn't get packaged up as part of that release a quick albeit inelegant solution is to build sos from source yourself. I'm sure it will complain that the version doesn't match, but in practice I suspect it will work.
tzwlai commentedon May 3, 2016
Closing this for now due to inactivity. Please feel free to reopen if needed.
EveryOtherUsernameWasAlreadyTaken commentedon May 30, 2016
@cshung: I'm trying to find out what happened to an app that crashed on a Raspberry Pi. In the dump, which I opened with WinDbg, I saw that CoreCLR was used (see the lm command). With this information, I knew it's a .NET universal app. Therefore I was looking for a debugging extension that could help me with the analysis of such a dump. From my previous .NET experience, I knew that there's an extension named SOS, so I tried loading any SOS extension I could find on my PC. However, none of them gave good results.
Regarding mrt100sos.dll, it was just a try. I didn't know what it was and it was the first time, I ever loaded it in WinDbg. I stumbled upon it while searching my hard drive for SOS.dll using Search Everything.
What am I trying to do? Well, just analyzing the dump like I would for any other dump I get.
EveryOtherUsernameWasAlreadyTaken commentedon May 30, 2016
@noahfalk: This was the first time I received an ARM crash dump and I didn't know anything about it, so I'm sorry for loading the wrong extension into WinDbg.
With that knowledge and the output of the lm command, we can say that this dump was of a CoreCLR runtime (JIT compiled). This is perfectly inline with the fact that the application ran on a Raspberry Pi 2 and AFAIK, there's no store to get applications on the Raspberry Pi. It is definitely possible that this was a debug build.
Debugging in Visual Studio may be fine, but still I prefer WinDbg + SOS for a couple of reasons:
EveryOtherUsernameWasAlreadyTaken commentedon May 30, 2016
Ok, I have the original dump file available again. If you like, I can run some WinDbg commands or try a few things now.
cshung commentedon May 31, 2016
Thanks for your extra information. Now we know what you are trying to do now.
As @noahfalk mentioned above, as of now (31st May 2016), there are two "flavors" of Universal Windows App execution. In DEBUG configuration, the code is JIT compiled and ran using CoreCLR.dll. In RELEASE configuration, the code is natively compiled and ran by itself with the help of mrt100_app.dll.
The DEBUG configuration is really meant for development time convenience because JIT compiled execution allows us to have a faster edit-compile-run cycle, it is not meant for production and therefore we don't have extensive support for post-mortem debugging (i.e. crash dump analysis)
The RELEASE configuration is for production, and we have support for debugging crash dump. !analyze -v should be able to pull down mrt100sos.dll for you and do the crash dump analysis for you. In typical scenarios, you should be able to access the crashing exception type and stack trace for it.
It appears from the conversation that you only have the dump that is running in DEBUG configuration, that is unfortunate because this scenario is not extensively supported. The first thing you will want to check is whether or not it is a mini-dump or a full-heap dump (you can tell from the size of the dump file). If it is a mini-dump, you are really out of luck because the critical information such as the method names are gone, all you have will be only JITTED address on the stack. If it is a full-heap dump, then you may still be able to try your luck using the SOS built in the CoreCLR repo.
In any case, if possible, repro the bug under the debugger when you remote debug into the Raspberry Pi, this is going to be the best solution if it is reproducible. If not, trying to re-deploy your app built in RELEASE configuration, that will at least allow you to have a useful crash dump.
EveryOtherUsernameWasAlreadyTaken commentedon Jun 6, 2016
It's a full dump (117 MB). So I guess I'll try to build SOS myself from the repo. I'm not sure if I have the necessary tool chain to build everything and I have almost no GIT experience. It may take a while.
Would it be possible to integrate SOS in the build script and provide it for download? This would tremendously increase the support level from "not extensively supported" to "at least it's available". I really got used to SOS during the past 7 years and it's hard to realize that it's some kind of "gone".
I can also understand if you finally reject this request. There are probably more important things to be done. Perhaps someone finds a way to perform the builds and provide inofficial downloads.
noahfalk commentedon Jun 6, 2016
@EveryOtherUsernameWasAlreadyTaken - I poked around a bit and sos is distributed in the CoreCLR nuget package. I don't know what version it first showed up in, but if you navigate to your nuget package cache you should find sos here:
packages\runtime.win7-x64.Microsoft.NETCore.Runtime.CoreCLR\1.0.2-rc3-24103-01\tools\sos.dll
If you are using an older version of the CoreCLR nuget package that doesn't have sos, you can likely download a newer version of the nuget package just to take SOS from it.You will get the version mismatch warning, but most things will probably work anyways. This should qualify for the "at least it's available" level of support : )
HppZ commentedon Dec 17, 2017
I use Windbg to debug a UWP app(in Debug mode), lm command shows that coreclr 4.6.25305.1 is loaded from C:\Program Files\WindowsApps\Microsoft.NET.CoreRuntime.1.1_1.1.25305.1_x64__8wekyb3d8bbwe, but no sos.dll exist in this folder, so:
1, Is there a way to download specific version of those debugging dlls?
2, I got sos.dll 4.6.25221.1 from https://github.com/dotnet/core/blob/master/release-notes/download-archives/1.1.2-download.md, but it is not 4.6.25305.1, so they don't match.
3, When is "Microsoft.NET.CoreRuntime.1.1_1.1.25305.1" released? no place to download it.
I think both live debugging and post-mortem debugging should be supported with Windbg, because Visual Studio is too big and not always available.