Repository navigation
Description
Description
When running dotnet-gcdump collect on a application that is using a large amount of memory the following exception occurs:
Exception:
63.5s: [Error] Exception during gcdump: System.ApplicationException: ETL file shows the start of a heap dump but not its completion.
at DotNetHeapDumpGraphReader.ConvertHeapDataToGraph() in //src/Tools/dotnet-gcdump/DotNetHeapDump/DotNetHeapDumpGraphReader.cs:line 512
at Microsoft.Diagnostics.Tools.GCDump.EventPipeDotNetHeapDumper.DumpFromEventPipe(CancellationToken ct, Int32 processID, MemoryGraph memoryGraph, TextWriter log, Int32 timeout, DotNetHeapInfo dotNetInfo) in //src/Tools/dotnet-gcdump/DotNetHeapDump/EventPipeDotNetHeapDumper.cs:line 205
[ 63.5s: Done Dumping .NET heap success=False]
Failed to collect gcdump. Try running with '-v' for more information.
I've looked into the source code and it seems like the exception gets thrown here:
diagnostics/src/Tools/dotnet-gcdump/DotNetHeapDump/DotNetHeapDumpGraphReader.cs
Lines 510 to 513 in a584d05
| if (!m_ignoreEvents) | |
| { | |
| throw new ApplicationException("ETL file shows the start of a heap dump but not its completion."); | |
| } |
I have created a repo to try and reproduce this issue:
Repo
This application creates objects and loads the memory. Collecting a gcdump when the application is around 200-800mb in memory usage, gcdump completes successfully. However, when the application reaches to about 1300mb the above exception occurs.
There are 2 other exceptions that I have come across while trying to reproduce the issue but I am not sure how relevant they are to the initial problem:
Exception 1:
and
Exception 2:
Any information as to why these exceptions are occurring would be a huge help.
Configuration
Tool: dotnet-gcdump
OS: LINUX and Win10
Environment: Issue happens either when containerized or as a standalone application.


Activity
tommcdon commentedon Jul 6, 2021
@josalem
josalem commentedon Jul 6, 2021
I'll try running the repro.
The logs in your screenshots imply that you aren't receiving all the data from the runtime. In the first case, the gc end event, and edge data in the second. Do you have a full log output from these failures with the
-vflag?I noticed your repro is shelling out to run
dotnet gcdumpevery 3 seconds. Is this happening on the first execution or only later ones? Every time you rundotnet-gcdumpyou incur a full gen2 GC which can get expensive if you're running it every 3 seconds. I'm assuming that is just for the repro, correct?I also noticed you are explicitly setting a long timeout (45 seconds). Does varying this change the behavior you observed?
If you collect a gcdump using PerfView under the same conditions, do you see similar errors?
iliamosko commentedon Jul 12, 2021
The 3 second timeout is just a pause in between successive
dotnet gcdumpcommands. There will be only one instance ofdotnet gcdumprunning. The nextdotnet gcdumpwill run 3 seconds after the deletion of the .gcdump file it has collected. The whole point of the repro is to see whendotnet gcdumpfails to collect a dump when the applications memory becomes to high.Either using the default timeout or setting a custom timeout for
dotnet gcdump, the outcome is still the same. I set a timeout of 45 seconds to see if maybe giving gcdump a bit more time that it will successfully collect a dump.I've tried collect a gcdump using Perfview, but it ran succesffully with no errors even when the applications memory usage exceeded 1200Mb.
Logs
I have 2 of the 3 output logs.
Log for 'Exception 1':
Log for 'Exception 2':
josalem commentedon Jul 12, 2021
Hmmm that is strange behavior indeed. The first log indicates that you didn't get a GC stop event for the GC you triggered (GC # 1494). The fact that it then observes a GC stop for GC # 1495 afterwards seems to indicate that the GC stop event either never was fired or the event itself was dropped. The second log indicates that it saw the Start/Stop event pair but is missing events in between.
Both logs show the tool observing many GCs besides the one that it triggered. I'm wondering if the number of GCs occurring is causing a high volume of events to be fired on the same keywords that
dotnet-gcdumpuses to collect dumps. If enough events are sent all at once, there's the possibility that the buffer size used by the tool is insufficient and there are enough dropped events to break dump collection functionality.When you tested with PerfView, did you do the same "request every 3 seconds" behavior or did you perform a one-off gcdump at 1200MB?
I have been focused on runtime work, so I haven't had a chance to loop back on this and check your repro.
iliamosko commentedon Jul 13, 2021
I just ran a one-off gcdump using PerfView. If I was to run a one-off dotnet-gcdump when the memory is 1200Mb, then it would show the same exception as 'Exception 1'.
I have the log from the gcdump command we ran on a production clone server. Right away we can see that the default timeout of the command is not being honored. The exception gets thrown at ~60s. Unlike the previous logs I have, there is no indicator that there is a problem with dotnet-gcdump.
Here is the log that we have received when running dotnet-gcdump on our production clone server:
liorss18 commentedon Dec 22, 2021
What's the status of this issue, as I suffer from the same thing as well.
Our process is 60gb.
We took the dump while the process was doing almost 0 work (i.e: almost 0 rps and 0 cpu).
It looks from the logs that gcdump misses the GCStop event with the relevant ID:
tommcdon commentedon May 31, 2022
@iliamosko @liorss18 we apologize for the delay. EventPipe through the diagnostics IPC channel is designed to be non-intrusive to program execution. Today gcdump uses the IPC channel to collect the events which means we could be dropping the GCEnd events even though we are sending the GCStart one. Large address spaces may cause the event pipe buffer to overflow with too many GC events. Couple ideas:
diagnostics/src/Tools/dotnet-gcdump/DotNetHeapDump/EventPipeDotNetHeapDumper.cs
Line 235 in 88b248d
Adding @noahfalk @josalem for thoughts.
noahfalk commentedon May 31, 2022
We did add a known issue to the docs about the overflow on large heaps. However short of implementing an EventPipe non-lossy mode (3 or 4) this issue is going to persist. I think the best solution for now on apps with very large heaps is to use dotnet-dump instead.
[IPC Protocol][dotnet-gcdump] Add non-lossy dotnet-gcdump mode (#5886)
[EventPipe] Add Blocking EventPipe Mode (#129457)