mark
mark

Reputation: 62866

.NET Core Dump - how to get the function param value if not on the stack?

I have a dump of the msbuild process which crashes with OutOfMemory exception in the following call stack:

0:053> !mk
Thread 53:
        SP       IP
00:U 0747e070 76fbf3ec ntdll!NtWaitForMultipleObjects+0xc
01:U 0747e074 74d64ae0 KERNELBASE!WaitForMultipleObjectsEx+0xf0
02:U 0747e208 74d649d8 KERNELBASE!WaitForMultipleObjects+0x18
03:U 0747e224 744971f2 kernel32!WerpReportFaultInternal+0x59d
04:U 0747e6a0 74496c36 kernel32!WerpReportFault+0x9b
05:U 0747e6bc 7446e629 kernel32!BasepReportFault+0x19
06:U 0747e6c4 74ded71a KERNELBASE!UnhandledExceptionFilter+0x25a
07:U 0747e75c 76fec6e1 ntdll!__RtlUserThreadStart+0x3be57
08:M 0747f584 718ab33b System.IO.MemoryStream.set_Capacity(Int32)(+0x57 IL,+0x5b Native)
09:M 0747f598 718ab3c3 System.IO.MemoryStream.EnsureCapacity(Int32)(+0x68 IL,+0x53 Native)
0a:M 0747f5a8 718b816a System.IO.MemoryStream.SetLength(Int64)(+0x60 IL,+0xba Native)
0b:M 0747f5c4 6ebe93e6 Microsoft.Build.BackEnd.NodeProviderOutOfProcBase+NodeContext.HeaderReadComplete(System.IAsyncResult)(+0x96 IL,+0x1f6 Native) [/_/src/Build/BackEnd/Components/Communications/NodeProviderOutOfProcBase.cs @ 959,17]
0c:M 0747f600 7032a6d6 System.IO.Pipes.PipeStream.AsyncPSCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)(+0xa6 Native)
0d:M 0747f618 7193565d System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)(+0x78 IL,+0x8d Native)
0e:U 0747fa70 76fb0884 ntdll!_RtlUserThreadStart+0x1b

Inspecting the stack frames does not help:

0:053> !mframe a
0:053> !mdv
Frame 0xa: (System.IO.MemoryStream.SetLength(Int64)):
[A0]:this: <UNAVAILABLE> (System.IO.MemoryStream)
[A1]:value: <UNAVAILABLE> (System.Int64)
[L0]: <UNAVAILABLE> (System.Int32)
[L1]: <UNAVAILABLE> (System.Boolean)

0:053> !mframe 9
0:053> !mdv
Frame 0x9: (System.IO.MemoryStream.EnsureCapacity(Int32)):
[A0]:this: <UNAVAILABLE> (System.IO.MemoryStream)
[A1]:value: <UNAVAILABLE> (System.Int32)
[L0]: <UNAVAILABLE> (System.Int32)

0:053> !mframe 8
0:053> !mdv
Frame 0x8: (System.IO.MemoryStream.set_Capacity(Int32)):
[A0]:this: <UNAVAILABLE> (System.IO.MemoryStream)
[A1]:value: <UNAVAILABLE> (System.Int32)
[L0]: <UNAVAILABLE> (System.Byte[])

There is nothing helpful, as far as I can see, on the stack:

0:053> !mdso
Thread 53:
Location          Object            Type
------------------------------------------------------------
0747e850  01a38ac0  System.Threading.Tasks.TplEtwProvider
0747ef54  01fe1ff0  System.Byte[]
0747ef58  01d09c04  System.Threading.OverlappedData
0747f20c  56301c60  Microsoft.Build.Framework.BuildEventContext
0747f2cc  55ff5128  System.OutOfMemoryException
0747f4ec  020fde88  System.IO.MemoryStream
0747f5ac  01c9f454  Microsoft.Build.BackEnd.NodeProviderOutOfProcBase+NodeContext
0747f730  01d09524  System.Threading.OverlappedData

Now I can inspect the System.IO.MemoryStream object to get its capacity BEFORE the attempt that causes the OOM (I assume that is the instance in question):

0:053> !mdt 020fde88
020fde88 (System.IO.MemoryStream)
    __identity:NULL (System.Object)
    _activeReadWriteTask:NULL (System.IO.Stream+ReadWriteTask)
    _asyncActiveSemaphore:NULL (System.Threading.SemaphoreSlim)
    _buffer:80011010 (System.Byte[])
    _origin:0x0 (System.Int32)
    _position:0x0 (System.Int32)
    _length:0x2d468088 (System.Int32)
    _capacity:0x2d468088 (System.Int32)
    _expandable:true (System.Boolean)
    _writable:true (System.Boolean)
    _exposable:true (System.Boolean)
    _isOpen:true (System.Boolean)
    _lastReadTask:NULL (System.Threading.Tasks.Task`1[[System.Int32, mscorlib]])

And it is already quite big - 0x2d468088 bytes, i.e. ~724MB and because its _length == _capacity it makes sense msbuild is trying to resize it even more and beyond the 724MB, which results in OOM.

What I am unable to understand is how can I get this new desired capacity from the dump, if at all?

I know it is probably insignificant in the analysis of this OOM, but for the sake of the science - is it possible to figure out this value from this dump?

Upvotes: 0

Views: 20

Answers (0)

Related Questions