Repository navigation
Description
Description
Environment
- .NET Runtime Version: 9.0.7
- Operating System: Linux Debian 12
- Architecture: x64
- GC Mode: Server GC
- Environment Variable:
DOTNET_GCName=libclrgc.so
Problem Description
We are running a .NET 9 server application in our production environment. The server application intermittently experiences a total freeze or deadlock, becoming completely unresponsive.
Observed Symptoms
When the freeze occurs, we observe the following:
- No Response: All HTTP API endpoints stop responding.
- No Logs: The application stops writing any new logs.
- Delayed Timers: We have
System.Threading.Timerinstances that are observed to trigger significantly later than their scheduled time, indicating the entire process is stalled. - Correlation with GC: The freeze often correlates with a high-activity GC period (e.g., GC pause times reported as > 2 seconds just before the incident).
- Process State: During the freeze,
htoportopshows the process's CPU usage drops to 0. - Thread Pool: The thread pool queue length drops to near 0, even as new requests should be queuing.
- Diagnostics Fail: Attempting to use
dotnet-stack reporton the hung process also hangs indefinitely and provides no output.
GDB Stack Traces
We successfully attached gdb to the hung process. We found that the vast majority of .NET TP Worker threads are idle, but a few critical threads seem to be involved in a deadlock.
1. Suspicious Stacks (Potential Deadlock)
Two threads, including the crucial .NET SynchManag thread, are stuck in __GI_cfsetispeed. This appears to be the core of the deadlock.
Thread 2 (Thread 0x7fb6b2fb56c0 (LWP 7) ".NET SynchManag"):
#0 0x00007fb6b38c121f in __GI_cfsetispeed (termios_p=0x7fb6b2fb4d78, speed=1) at ../sysdeps/unix/sysv/linux/speed.c:96
#1 0x00007fb6b2fb4db0 in ?? ()
#2 0x00007fb6b2fb4d78 in ?? ()
#3 0x0000000000000001 in ?? ()
#4 0xffffffff00000000 in ?? ()
#5 0x000055a8504b0f58 in ?? ()
#6 0x00007fb6b3628fa0 in ?? () from /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.7/libcoreclr.so
#7 0x00007fb6b3628603 in ?? () from /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.7/libcoreclr.so
#8 0x00007fb6b363214e in ?? () from /usr/share/dotnet/shared/Microsoft.NETCore.App/9.0.7/libcoreclr.so
#9 0x00007fb6b384e1f5 in __pthread_create_2_1 (newthread=<optimized out>, attr=<optimized out>, start_routine=<optimized out>, arg=<optimized out>) at ./nptl/pthread_create.c:846
#10 0x0000000000000000 in ?? ()
Thread 181 (Thread 0x7e83927fc6c0 (LWP 255) "rdk:broker10265"):
#0 0x00007fb6b38c121f in __GI_cfsetispeed (termios_p=0x7e83740049b8, speed=2) at ../sysdeps/unix/sysv/linux/speed.c:96
#1# 0x0000000000000000 in ?? ()
2. Idle Worker Threads
Most other threads, especially .NET TP Worker threads, are idle and appear to be waiting for work (stuck in __pthread_attr_extension).
Thread 194 (Thread 0x7e8651ffb6c0 (LWP 311668) ".NET TP Worker"):
#0 0x00007fb6b384af16 in __pthread_attr_extension (attr=0x0) at ./nptl/pthread_attr_extension.c:30
#1 0x0000000000000189 in ?? ()
#2 0x000055a8504e83b8 in ?? ()
#3 0x0000000000000000 in ?? ()
Thread 193 (Thread 0x7e84fdffb6c0 (LWP 311660) ".NET TP Worker"):
#0 0x00007fb6b384af16 in __pthread_attr_extension (attr=0x0) at ./nptl/pthread_attr_extension.c:30
#1 0x000055a800000189 in ?? ()
#2 0x000055a8504e83b8 in ?? ()
#3 0x0000000000000000 in ?? ()
Thread 192 (Thread 0x7e851effd6c0 (LWP 311650) ".NET TP Worker"):
#0 0x00007fb6b384af16 in __pthread_attr_extension (attr=0x0) at ./nptl/pthread_attr_extension.c:30
#1 0x0000000000000189 in ?? ()
#2 0x000055a8504e83b8 in ?? ()
#3 0x0000000000000000 in ?? ()
Summary
The presence of __GI_cfsetispeed in the stack for the .NET SynchManag thread is highly suspicious and suggests a potential native-level deadlock, possibly within glibc or how the runtime interacts with it. This stall prevents all managed code (including timers and the thread pool) from making progress.
Given that diagnostic tools like dotnet-stack also fail, this points to a very low-level lock or stall.
Reproduction Steps
Hard to reproduce, occured sometimes in production environment
Expected behavior
Should not hang forever
Actual behavior
Hangs forever
Regression?
No response
Known Workarounds
No response
Configuration
- .NET Runtime Version: 9.0.7
- Operating System: Linux (inferred from stack trace)
- Architecture: x64 (inferred from stack trace)
- GC Mode: Server GC
- Environment Variable:
DOTNET_GCName=libclrgc.so
Other information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
am11 commentedon Nov 8, 2025
Do you have full backtrace to
__GI_cfsetispeed? You can usedotnet symbolto download the native runtime symbols:$ dotnet tool install --global dotnet-symbol $ dotnet symbol --recurse-subdirectories --timeout 20 --symbols '/usr/share/dotnet/*.so'The only place we are (explicitly) calling
cfsetispeed(3p)is insrc/native/libs/System.IO.Ports.Native/pal_termios.c, so unless you are using System.IO.Ports to connect to serial/comm interfaces etc. that's likely something outside the runtime causing it.vrecluse commentedon Nov 8, 2025
No, the server has been restarted. We don't use System.IO.Ports directly. Any other clues or workarounds? What can I do if next time it happens again?
am11 commentedon Nov 8, 2025
It would be nice if you could get the native symbols uploaded to the server then capture the error logs and/or coredump.
For selfhosted/singlefile publish, you could uploaded the .dbg file(s) by running dotnet-symbol command on build machine. For framework-dependent deployment (e.g. on VM server), you could run dotnet-symbol command on the target machine as shown above (which will place .dbg files for all native libs like libcoreclr.so etc. next to the shared libs).
vrecluse commentedon Nov 8, 2025
I captured core dump with gcore.
Does this commands require excactly the same environment as the core dump generated (os version, dotnet runtime version, etc)?
am11 commentedon Nov 9, 2025
It depends on how you published the app. If you are using:
framework-dependent deployment(i.e. you have dotnet runtime installed on the server), then you'd need to rundotnet symbol --recurse..command on the server by adjusting the path to dotnet install directory.find /path/to/your-publish-dir -type f -exec sh -c 'for f; do file -L --mime-type "$f" 2>/dev/null | grep -qE "application/x-(sharedlib|(pie-)?executable)" && echo "$f"; done' _ {} + | xargs dotnet symbol --timeout 20dotnet-policy-service commentedon Nov 10, 2025
Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.
vrecluse commentedon Nov 11, 2025
It's
framework-dependent deploymenton k8s. The noted stacks with symbols:The other call stacks are still like
@am11
vrecluse commentedon Nov 11, 2025
related locals:
am11 commentedon Nov 11, 2025
.NET SynchManagthread might not be interesting, but BGC ones seem like runtime is stalling in GC (probably due to contention arounds_csSynchProcessLock?)cc @janvorli
janvorli commentedon Nov 11, 2025
@vrecluse could you please capture the stack traces using lldb instead of gdb? GDB is unable to walk frames of the .NET managed code and usually a first managed frame puts it off the rails.
6 remaining items
vrecluse commentedon Nov 12, 2025
Is this thread suspicious? No GCEvent::Wait on stack:
@jkotas
vrecluse commentedon Nov 12, 2025
Here are stacks without GCEvent::Impl::Wait
nogcwait.txt
janvorli commentedon Nov 12, 2025
@vrecluse can you please run
clrthreadsinstead ofsos threads?vrecluse commentedon Nov 12, 2025
@janvorli seems all preemptive
jkotas commentedon Nov 12, 2025
This is invalid analysis.
This thread is not suspicious. The thread is blocked inside P/Invoke, nothing problematic about that.
jkotas commentedon Nov 12, 2025
It means that the thread suspension succeeded, but the GC is not making progress for some reason. It would be interesting to find the thread that owns the thread store lock. Could you please dump the value
ThreadStore::s_pThreadStore->m_HoldingThread?It is possible that you are hitting this glibc bug: #47700 (comment) . Ubuntu has a workaround for it, but I am not sure whether the workaround is 100% reliable. Any chance you can check whether this problem happens with .NET 10 too? We have refactored some of the runtime internals in .NET 10 to make it less prone to this glibc bug.
vrecluse commentedon Nov 13, 2025
@jkotas
We are using debian 12, based on the official dotnet 9 docker image:
Is it helpful if we update os to new version?
Btw, we found this in kafka c library, is it related to that glibc bug? @jkotas
vrecluse commentedon Nov 13, 2025
#47700 (comment)
This issue seems been fixed in version 2.41
.Net 9 sdk image is using 2.36
vrecluse commentedon Nov 13, 2025
Maybe updating debian to trixie (which includes glibc 2.42) can fix this problem?
Or change to ubuntu noble (glibc version 2.39, fixed in 2.32)?
https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1899800
jkotas commentedon Nov 13, 2025
The default docker images switched to Ubuntu in .NET 10: https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/10.0/default-images-use-ubuntu
You can get .NET 9 docker images based on Ubuntu Noble via 9.0-noble tag. https://github.com/dotnet/dotnet-docker/blob/main/README.aspnet.md#linux-amd64-tags
jkotas commentedon Nov 13, 2025
So this is the lock that's everything is stuck on:
It matches the symptoms of the glibc bug.
Upgrading to .NET 10 and/or switching to Ubuntu-based container should fix it,
vrecluse commentedon Nov 13, 2025
Ok, thanks.