clrmd - Getting System.Runtime.InteropServices.SEHException After using DataTarget.CreateSnapshotAndAttach

0

I'm want to get c# object inclusive size by using clrmd API. In order to get this information, first I need to attach to the process. To achieve this, I'm using DataTarget.CreateSnapshotAndAttach method.

For some reason, the application crash after getting System.Runtime.InteropServices.SEHException exception with 0x80004005 Error Code

StackTrace:

   at Microsoft.Win32.SafeNativeMethods.CloseHandle(IntPtr handle)
   at Microsoft.Win32.SafeHandles.SafeProcessHandle.ReleaseHandle()
   at System.Runtime.InteropServices.SafeHandle.InternalFinalize()
   at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
   at System.Runtime.InteropServices.SafeHandle.Finalize()

The root cause for this problem is an exception from the GC Finalizer Thread.

How can I bypass or prevent this exception?

Full code example:

public static void Main(string[] args)
{
    var processId = Process.GetCurrentProcess().Id;

    using (var dataTarget = DataTarget.CreateSnapshotAndAttach(processId))
    {
    }

    GC.Collect();
    GC.WaitForPendingFinalizers(); // Will cause exception
}

Update: When I "Start Without Debugging", I don't get the exception. But I want to debug.

c#
garbage-collection
profiling
clrmd
asked on Stack Overflow Sep 6, 2019 by itaiy • edited Sep 14, 2019 by itaiy

1 Answer

0

clrmd fix it and support it from version 1.1.57604.

answered on Stack Overflow Dec 3, 2019 by itaiy

User contributions licensed under CC BY-SA 3.0