If you have memory dumps, I would suggest using WinDbg to look at them, assuming you are not already doing this.
Try to start the comment !EEStack (mixed tracing using its own and managed stacks) and see if there is anything that can pop up in the stack trace. In my test program, I found this once as a stack trace where FEEE occurred (I deliberately distorted the heap):
0: 000>! EEStack
---------------------------------------------
Thread 0
Current frame: ntdll! NtWaitForSingleObject + 0xa
Child-SP RetAddr Caller, Callee
00000089879bd3d0 000007fc586610ea KERNELBASE! WaitForSingleObjectEx + 0x92, calling ntdll! NtWaitForSingleObject
00000089879bd400 000007fc5869811c KERNELBASE! RaiseException + 0x68, calling ntdll! RtlRaiseException
[...]
00000089879bec80 000007fc49109cf6 clr! WKS :: gc_heap :: gc1 + 0x96, calling clr! WKS :: gc_heap :: mark_phase
00000089879becd0 000007fc49109c21 clr! WKS :: gc_heap :: garbage_collect + 0x222, calling clr! WKS :: gc_heap :: gc1
00000089879bed10 000007fc491092f1 clr! WKS :: GCHeap :: RestartEE + 0xa2, calling clr! Thread :: ResumeRuntime
00000089879bed60 000007fc4910998d clr! WKS :: GCHeap :: GarbageCollectGeneration + 0xdd, calling clr! WKS :: gc_heap :: garbage_collect
00000089879bedb0 000007fc4910df9c clr! WKS :: GCHeap :: Alloc + 0x31b, calling clr! WKS :: GCHeap :: GarbageCollectGeneration
00000089879bee00 000007fc48ff82e1 clr! JIT_NewArr1 + 0x481
Since this may be due to damage to the heap from the garbage collector, I would try the !VerifyHeap . At the very least, you can make sure that the heap is not damaged (and your problem lies elsewhere) or find that your problem may be related to the GC or some P / Invoke procedures that decompose it.
If you find that the heap is damaged, I can try to figure out what part of the heap is damaged, which you can do with !HeapStat . It can just show the whole bunch of corrupt ones from a certain point, however.
It is difficult to suggest any other methods for analyzing this through WinDbg, since I do not know what your code does and how it is structured.
I suggest that if you find this to be a heap problem, and therefore it means that it could be GC weirdness, I would look at the GC CLR events in the event trace for Windows.
If the mini-disks you get do not cut it and you use Windows 7 / 2008R2 or later, you can use Global Flags (gflags.exe) to attach the debugger when the process completes without exception, if you do not receive a notification Wer.
On the Silent Process Exit tab, enter the name of the executable file, not the full path to it (i.e. TestProgram.exe ). Use the following settings:
- Check "Enable output monitoring without sound"
- Check the launch process
- For the monitoring process, use
{path to debugging tools}\cdb.exe -server tcp:port=5005 -g -G -p %e .
And apply the settings.
When your test program crashes, cdb will connect and wait until you connect to it. Run WinDbg, enter Ctrl + R and use the connection string: tcp:port=5005,server=localhost .
You might be able to skip using remote debugging and use {path to debugging tools}\windbg.exe %e . However, the reason I suggested the remote option was because WerFault.exe , which I believe is reading the registry and starting the monitoring process, will start the debugger in session 0.
You can make session 0 interactive and connect to the window station, but I don’t remember how it was done. This is also inconvenient because you have to switch between sessions if you need to access any of your existing windows that you have opened.