fremag / MemoScope.Net

Dump and analyze .Net applications memory ( a gui for WinDbg and ClrMd )
The Unlicense
693 stars 75 forks source link

"Unable to find dac file" error when trying to load dump from another machine #209

Closed Zero3 closed 5 years ago

Zero3 commented 5 years ago

When trying to load a .DMP file that was dumped using Task Manager on another machine, I get the following error:

Failed to initRuntime:

Exception: Unable to find dac file 'mscordacwks_Amd64_Amd64_4.7.3394.00.dll' in symbol server.

I'm guessing I will need to fetch that file from the other machine and supply it to MemoScope.Net, but I don't see any such functionality in the interface.

I think this is a bug or a limitation that perhaps should be looked into.

(Feel free to close this issue if it it caused by my own stupidity. I'm new to this dump analysis stuff.)

fremag commented 5 years ago

This dll file should be downloaded automatically from Microsoft symbol server.

Are you behind a firewall or do you use a proxy ?

gnh1201 commented 5 years ago

A little fortunately, I can download the mscordacwks(x86 or amd64) dll file at: https://sos.debugging.wellisolutions.de/ I was copy the file to a directory listed in the PATH variable such as \\Windows\System32. but it did not fix the same error. How should I solve it?

fremag commented 5 years ago

Unfortunately I'm not a specialist of all underlying dump processes : Memoscope is just a GUI on top of ClrMd

When I load a dump file, Memoscope / ClrMd downloads a dll from a Microsoft server to get the symbols matching the .Net version used to run the dumped application.

The dll is saved on the disk, for instance, on my computer, it's here: .\MemoScope_x64_Release\DacSymbols\mscordacwks_Amd64_Amd64_4.7.2661.00.dll\5AC796639e8000\mscordacwks_Amd64_Amd64_4.7.2661.00.dll

(.\MemoScope_x64_Release is the directory where I unzip the Memoscop release)

Hope this helps...

fremag commented 5 years ago

It looks like there are some tools when the automatic download doesn't work: Getting Symbols Manually

Zero3 commented 5 years ago

This dll file should be downloaded automatically from Microsoft symbol server.

Are you behind a firewall or do you use a proxy ?

Nop, nothing really. Also, symbol loading works fine in Visual Studio, for example.

I will try out some things and let you know if I find a solution.

i00 commented 5 years ago

Same issue here ... happening on all PCs I have tried on though ... even the one that does the dump!

fremag commented 5 years ago

I got it too so I could made some tests. TL/DR: I think you dumped a x86 application with a x64 tool. Try to dump it with x86 task manager and then load it with Memoscope x86.

I loaded my dump file with Visual Studio and got this:

image

Look at the "Process architecture": x86 (64- bit dump) It should be "x64" like this: image

If you dump a x86 process from Windows 64, you need to use the x86 task manager (in C:\Windows\SysWOW64\taskmgr.exe). Check the wiki for more details about x86/x64 for more details.

fremag commented 5 years ago

I have two dump files: the first one (Ok.dmp) is loaded by Memoscope, the second one (Fail.dmp) is not laded and I got the same error message as you.

I wrote a small program, using only Microsoft libs to see what happens with these files.

using System;
using Microsoft.Diagnostics.Runtime;

namespace DumpReader
{
    class Program
    {
        static void Main()
        {
            var dumpFile1 = @"E:\Dumps\Test\Ok.dmp";
            var dumpFile2 = @"E:\Dumps\Test\Fail.dmp";

            Test(dumpFile1);
            Test(dumpFile2);
        }

        private static void Test(string dumpFile)
        {
            Console.WriteLine("***************************************");
            Console.WriteLine($"Dump file: {dumpFile}");

            using DataTarget dataTarget = DataTarget.LoadCrashDump(dumpFile);
            foreach (ClrInfo version in dataTarget.ClrVersions)
            {
                Console.WriteLine($"CLR Version: {version.Version}");
                ModuleInfo dacInfo = version.DacInfo;
                Console.WriteLine($"Dac File:  {dacInfo.FileName}");
                ClrInfo runtimeInfo = dataTarget.ClrVersions[0];
                ClrRuntime runtime = runtimeInfo.CreateRuntime();

                var runtimeClrInfo = runtime.ClrInfo;
                Console.WriteLine($"ClrInfo Version: {runtimeClrInfo.Version}");

                Console.WriteLine($"ModuleInfo File: {runtimeClrInfo.ModuleInfo.FileName}");
            }
        }
    }
}

And I get this result:


Dump file: E:\Dumps\Test\Ok.dmp CLR Version: v4.7.3394.00 Dac File: mscordacwks_Amd64_Amd64_4.7.3394.00.dll ClrInfo Version: v4.7.3394.00 ModuleInfo File: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll


Dump file: E:\Dumps\Test\Fail.dmp CLR Version: v4.7.3394.00 Dac File: mscordacwks_Amd64_Amd64_4.7.3394.00.dll Unhandled exception. System.IO.FileNotFoundException: Could not find matching DAC for this runtime. File name: 'mscordacwks_Amd64_Amd64_4.7.3394.00.dll' at Microsoft.Diagnostics.Runtime.DataTarget.CreateRuntime(ClrInfo clrInfo) at Microsoft.Diagnostics.Runtime.ClrInfo.CreateRuntime() at DumpReader.Program.Test(String dumpFile) in C:\Homeware\Projects\ClrMd\ClrMd\DumpReader Program.cs:line 31 at DumpReader.Program.Main() in C:\Homeware\Projects\ClrMd\ClrMd\DumpReader\Program.cs:line 14

fremag commented 5 years ago

I tried to load the file with WinDbg and got some errors too;

fremag commented 5 years ago

@Zero3 @gnh1201 @i00 : tell me if it's OK for you so I can close the issue.