fremag / MemoScope.Net

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

NullReferenceException during memorydump load #196

Closed dobrou closed 7 years ago

dobrou commented 7 years ago

MemoScope.Net: x64 v0.9.999.210 Memory dump: x64, +-8GB Loading memory dump gives me after ~10 minutes System.NullReferenceException with following call stack:

   at MemoScope.Core.Cache.ClrDumpCache.LoadTypeStat() in C:\projects\memoscope-net\MemoScope\Core\Cache\ClrDumpCache.cs:line 179
   at MemoScope.Modules.TypeStats.TypeStatModule.Init() in C:\projects\memoscope-net\MemoScope\Modules\TypeStats\TypeStatModule.cs:line 45
   at WinFwk.UIModules.UIModuleFactory.InitModule[T](T module)
fremag commented 7 years ago

Hi,

Thanks for the feedback. Sometimes, dump files are corrupted (if it's dumped during GC for instance) and its content is not as expected. I would be really interresed to have a look at it in debug mode to add more error checks in MemoScope to avoid it to crash and display a message for the user. Is it possible to send me the dump file you're loading ? (Google drive for instance or any other way ?)

The version you're using is the last build but the stracktrace information is not matching the source code. I mean, one call to "ClrDumpCache.LoadTypeStat()" is made from : "TypeStatModule.cs:line 45" but in the source code, it should be line 48.

Could you try to reopen your dump file with the debug version and tell me what happens then ?

Thanks for your help.

dobrou commented 7 years ago

Hi, I loaded dump in debug version MemoScope_x64_Debug.zip. Here is the exception call stack:

   at MemoScope.Core.ClrTypeStats..ctor(Int32 id, ClrType type) in C:\projects\memoscope-net\MemoScope\Core\ClrTypeStats.cs:line 26
   at MemoScope.Core.ClrTypeStats..ctor(Int32 id, ClrType type, Int64 nbInstances, UInt64 totalSize) in C:\projects\memoscope-net\MemoScope\Core\ClrTypeStats.cs:line 30
   at MemoScope.Core.Cache.ClrDumpCache.LoadTypeStat() in C:\projects\memoscope-net\MemoScope\Core\Cache\ClrDumpCache.cs:line 179
   at MemoScope.Core.ClrDump.GetTypeStats() in C:\projects\memoscope-net\MemoScope\Core\ClrDump.cs:line 126
   at MemoScope.Modules.TypeStats.TypeStatModule.Init() in C:\projects\memoscope-net\MemoScope\Modules\TypeStats\TypeStatModule.cs:line 48
   at WinFwk.UIModules.UIModuleFactory.InitModule[T](T module)

From first look into MemoScope source code, it looks like ClrMd returned 'null' as type for some object. I already saw this ClrMd behavior several times. You are right that dump is taken during GC, so it may be the reason. However I didn't see any other issue with the dump file when I processed it with my LinqPad+ClrMd scripts.

Unfortunately I can not share the memory dump file. I hope above call stack will be sufficient. If not, let me know what else should I try.

Thanks for interesting tool.

fremag commented 7 years ago

Thanks for your help. I think I will have to add more checks about null type or introduce a default 'UnknownType' to handle this.

I'm away from keyboard at the moment so I'll do this next week.

fremag commented 7 years ago

I created a branch "iclrtype" with some commits trying to solve the nullreference issue. I tried to dump a process while garbage collector is working but all my dump files could be loaded anyway. If you still have yours and can pull the branch, I'll be happy to hear if the commit fixes things or not. Thanks for your help.