-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application freezes during GC #108144
Comments
Tagging subscribers to this area: @dotnet/gc |
Hello @FlorianRoudautOrchestrade, can you please indicate which thread you feel is causing the deadlock? I dont see any indication in the stacks attached. Also is the Freeze transient or once you hit it it never unfreezes? |
Hello, We have seen no clue indicating a deadlock. Most of the threads are shown as "Active" when opening the dump in visual studio. It's just that they are all waiting for GC. When we take other dumps, a bit later ( could be 10 seconds or 10 minutes later), all the threads are in the exact same stack trace. The freeze is not stopping, we've left the application running for hours and did not unfreeze |
Can you please elaborate on "Every tool indicates that the process is stuck in a GC cycle"? Are you seeing a single GC spin effectively forever, or are there repeated GCs occurring? To get more insight into the GC behavior, a gc collect only trace would be very helpful; please see https://github.com/Maoni0/mem-doc/blob/master/doc/.NETMemoryPerformanceAnalysis.md#how-to-collect-top-level-gc-metrics. |
To reply to the second question : " Are you seeing a single GC spin effectively forever, or are there repeated GCs occurring ". To reply "Every tool indicates that the process is stuck in a GC cycle" , I've attached the debug diag analysis We can see numerous threads in : ntdll!NtWaitForSingleObject+14 or ntdll!NtWaitForSingleObject+14 or ntdll!NtWaitForSingleObject+14 Each time, there is a function in the stack mentionning waiting for GC to be completed |
I don't see any thread actually performing GC, so this seems to be in thread suspension for GC or something interfering with that. One idea could be to look at the threads that are not waiting for GC to see if there is anything in the app. I suspect that for us to find anything more, we would need to look at the dumps if that is possible - if so, could you please share some from a few different freezes via https://developercommunity.visualstudio.com/dotnet? This would let us look for more details, and seeing more than one might expose things in common between them. |
the recommendation from DebugDiag just says
this is not saying "this process is stuck in a GC cycle". it just says too many GCs are bad for perf in a process. it's very understandable you'd see threads waiting for GC to complete because a GC probably did just happen - you have 65 threads, most of which are managed threads, and one GC heap since you are using Workstation GC. so you probably were triggering lots of GCs (but DebugDiag does not have this knowledge because it doesn't have a way to know that from a dump). and when you were capturing the dump, the profiler (JetBrains) is trying to enumerate threads in this process and it's waiting on the thread store lock which is probably still held by the thread that last triggered a GC -
this could mean you happened to have just triggered a GC which landed you in this situation, or you were triggering lots of GCs (which was most likely your case since you mentioned your time in GC is so high) so it's very likely that every time you capture a dump you will see something similar. this is where a trace would be useful if you still have the repro. but from just these callstacks I don't see anything unusual, especially for a process that is doing lots of GCs. |
Thank you both for having a look. @markples I've created this case and uplaoded the dumps on it https://developercommunity.visualstudio.com/t/Application-freezes-during-GC-github-ca/10753082 @Maoni0 We see that having a lot of GC is bad. Our code is allocating a fair memory, especially when doing computations on 24 or 32 threads. But that's the best way we found to minimize computation time. It can run fine for days or hours. The issue is that in this case the winforms application is Not Responding, and when we take dumps at different time, the stacks are exactly the same, so we have excluded that GC has worked, calculation resumed and a new GC happened when we took the new dump. We tried to trace what is happening during the freeze but dotnet-trace gave a tcp timeout exception and DotTrace was not able to attach to the process either in Timeline or Sampling mode. Do you have an idea on what tool we could use to analyze further? |
The most useful thing would be a trace so that the history up to the freeze can be seen. From the link above, you can use the command |
Hello, Thank you. I'll check with the users to set that up. It may take a couple of weeks |
In dumps that you have shared, the thread that is expected to complete the GC is blocked by:
The code in this .dll intercepted execution of the GC thread and it is spinning in some sort of spinlock. This looks like a bug in SentinelOne software. To validate this theory, you can try disabling the SentinelOne software and see whether the hang will go away. You may want to contact SentinelOne support to diagnose it further. |
Thank you very much Jan. How did you spot that? |
To find the thread that is expected to execute the GC, open the crash dump in windbg debugger, run The stacktrace of the thread that is expected to execute the GC as shown by the windbg debugger is incomprehensible since there are no symbols and stackunwinding information for InProcessClient64:
|
Thank you very much Jan |
|
Looks like this is affecting Paint.NET 5.1 on .NET 9.0.0. I'm getting reports of it hanging at app startup, and the dump I looked at shows that it's parked on Is there any known reliable workaround, like disabling Tiered Compilation or ReadyToRun or something? |
Link to discussion about this over on the Paint.NET forum: https://forums.getpaint.net/topic/131939-paintnet-51-not-starting-properly/ |
Did you see a thread spinning inside InProcessClient64.dll with a callstack like #108144 (comment)?
My guess is that the hang in SentinelOne got exposed by changes in GC thread suspension. There have been quite a few changes around GC thread suspension to make it simpler, more scalable and compatible with CET. For example, #99076 may be related (just a speculation). If you would like to go on an adventure to prove or disprove this theory, you can try setting |
Yeah, I see on the UI thread: (this is from VS looking at the DMP)
The This might not even be related to GC changes in .NET 9 -- I say this because you mention Oh, and the ".NET System Events" thread has this, although I can't tell if it's also snagged or doing just fine:
|
|
Well, cross your fingers |
Description
One of our Winforms applications, with workstation gc, randomly freezes. The application is running on laptops and doing multithreaded (around 24 or 32 threads) calculations that involves a high memory allocation and deallocation.
Freezes could happens 2 or 3 times a day. The desktop application is running almost 24/7 on the user machine. Ona a usual cycle, we can see with DotMemory that around 35% of the time is spent in GC.
During the freeze we see in the Task Manager that the application is taking around 5GB, while total used is around 40GBand the machine has 64GB available. The Task Manager also shows CPU activity (around 4% on a machine with 24 virtual CPUs).
We have taken dumps and used various tools. Every tool indicates that the process is stuck in a GC cycle. We can analyze the dump using dotnet-dump and the output of clrstack -all is in the file attached.
clrstack.txt
Reproduction Steps
No controlled reproduction available.
Expected behavior
We expect the Garbage colletion to continue and not freeze the application.
Actual behavior
The application is unresponsive
Regression?
No response
Known Workarounds
We are decreasing the number of threads launched. With 8 threads, the freeze happens much less often.
Configuration
.NET Runtime 8.0.8
Windows 11
x64
Other information
No response
The text was updated successfully, but these errors were encountered: