Skip to content

Deadlock in GC #105780

@jhudsoncedaron

Description

@jhudsoncedaron

Description

Active worker thread is hung up with a diagnostic call stack that looks something like this:

ntdll.dll!syscall_gate
KERNELBASE.dll!WaitForMultipleObjects
???
CORINFO_HELP_NEWARR_1_VC
inlined!StringBuilder.ctor
Cedaron.Common.HL7.DLL!Cedaron.Common.HL7.HL7Segment.HL7Decode

All managed stacks as follows:

Main thread:
 	ntdll.dll!00007ff9df400d24()	Unknown
 	KERNELBASE.dll!00007ff9dc9d464c()	WaitForSingleObject
 	[Managed to Native Transition]	
 	System.Private.CoreLib.dll!System.Threading.Monitor.Wait(object obj, int millisecondsTimeout) Line 156	C#
 	System.Private.CoreLib.dll!System.Threading.ManualResetEventSlim.Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Line 561	C#
 	System.Private.CoreLib.dll!System.Threading.Tasks.Task.SpinThenBlockingWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Line 3072	C#
 	System.Private.CoreLib.dll!System.Threading.Tasks.Task.InternalWaitCore(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Line 3007	C#
 	System.Private.CoreLib.dll!System.Threading.Tasks.Task.Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Line 2768	C#
 	System.Private.CoreLib.dll!System.Threading.Tasks.Task.Wait(int millisecondsTimeout) Line 2728	C#
 	[Waiting on Async Operation, double-click or press enter to view Async Call Stacks]	
	System.IO.FileSystem.Watcher.dll!System.IO.FileSystemWatcher.WaitForChanged(System.IO.WatcherChangeTypes changeType, int timeout) Line 631	C#
 	Cedaron.Interface.Engine.dll!Cedaron.Interface.Engine.Program.Main(string[] args) Line 300	C#

Background task scheduler thread:
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	[Managed to Native Transition]	
 	Cedaron.Common.dll!Cedaron.Common.Portable.MultiWaiter.Win32WaitForAnyObject(nint[] waithandle, int tv_sec, int tv_msec)	Unknown
 	Cedaron.Common.dll!Cedaron.Common.Portable.MultiWaiter.WaitForAnyRead(System.Collections.Generic.IList<Cedaron.Common.Either<System.Net.Sockets.Socket, Cedaron.Common.Portable.IMultiWaitable>> waitfor, int tv_sec, int tv_msec)	Unknown
	Cedaron.Interface.Engine.dll!Cedaron.Interface.Engine.InterfaceEngine.BackgroundJobRunner()

Background keepalive thread:
 	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	[Managed to Native Transition]	
	System.Private.CoreLib.dll!System.Threading.Thread.Sleep(int millisecondsTimeout) Line 367	C#
 	Cedaron.Interface.FormBuilder.dll!Cedaron.Interface.FormBuilder.APIConfiguration.RefreshToken()	Unknown

.NET TP Gate:
 	ntdll.dll!00007ff9df400d24()	Unknown
 	KERNELBASE.dll!00007ff9dc9d464c()	WaitForSingleObject
 	[Managed to Native Transition]	
>	System.Private.CoreLib.dll!System.Threading.WaitHandle.WaitOneNoCheck(int millisecondsTimeout) Line 128	C#
 	System.Private.CoreLib.dll!System.Threading.PortableThreadPool.GateThread.GateThreadStart() Line 48	C#

.NET ThreadPool IO:
 	ntdll.dll!00007ff9df4030c4()	Unknown
 	KERNELBASE.dll!00007ff9dcab2724()	Unknown
 	[Managed to Native Transition]	
>	System.Private.CoreLib.dll!System.Threading.PortableThreadPool.IOCompletionPoller.Poll() Line 188	C#

.NET Timer:
 	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	[Managed to Native Transition]	
>	System.Private.CoreLib.dll!System.Threading.WaitHandle.WaitOneNoCheck(int millisecondsTimeout) Line 128	C#
 	System.Private.CoreLib.dll!System.Threading.TimerQueue.TimerThread() Line 87	C#

Connection Listener:
 	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	[Managed to Native Transition]	
 	Cedaron.Common.dll!Cedaron.Common.Portable.MultiWaiter.Win32WaitForAnyObject(nint[] waithandle, int tv_sec, int tv_msec)	Unknown
 	Cedaron.Common.dll!Cedaron.Common.Portable.MultiWaiter.WaitForAnyRead(System.Collections.Generic.IList<Cedaron.Common.Either<System.Net.Sockets.Socket, Cedaron.Common.Portable.IMultiWaitable>> waitfor, int tv_sec, int tv_msec)	Unknown
 	Cedaron.HL7.Client.dll!Cedaron.HL7.Client.SocketTransport.GetConnected(System.Action monitor, int monitorinterval)	Unknown
>	Cedaron.Interface.Engine.dll!Cedaron.Interface.Receivers.TCP.Cedaron.Interface.Declarations.IInterfaceReceiver.ReceiveLoop()
 	Cedaron.Interface.Engine.dll!Cedaron.Interface.Engine.Interface.ReceiveLoop()

.NET Finalizer:
>	ntdll.dll!00007ff9df400d24()	Unknown
 	KERNELBASE.dll!00007ff9dc9d464c()	WaitForSingleObject
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET Server GC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

Only Active Worker Thread:
 	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	[Managed to Native Transition]	
>	Cedaron.Common.HL7.dll!Cedaron.Common.HL7.HL7Segment.HL7Decode(string data, int offset, int length, char msh1, string msh2, bool translateunknownesc) Line 391	C#
 	Cedaron.Common.HL7.dll!Cedaron.Common.HL7.HL7Segment.HL7Segment(string msgdata, int offset, int length, char msh1, string msh2, bool translateunknownesc) Line 300	C#
 	Cedaron.Common.HL7.dll!Cedaron.Common.HL7.HL7Message.HL7Message(byte[] message, int offset, int length, bool translateunknownesc) Line 523	C#
 	Cedaron.Interface.FormBuilder.dll!Cedaron.Interface.FormBuilder.ADT.UpdateManualPromoteRecords()
 	Cedaron.Interface.FormBuilder.dll!Cedaron.Interface.FormBuilder.ADT.ProcessADT()
 	Cedaron.Interface.FormBuilder.dll!Cedaron.Interface.FormBuilder.ADT.Cedaron.Interface.Declarations.IMessageProcessor.ProcessMessage()
 	Cedaron.Interface.FormBuilder.dll!Cedaron.Interface.FormBuilder.DatabaseArchiver.Cedaron.Interface.Declarations.IMessageProcessor.ProcessMessage()
 	Cedaron.Interface.Engine.dll!Cedaron.Interface.Engine.Interface.ProcessMessage()
 	Cedaron.Interface.Engine.dll!Cedaron.Interface.Receivers.TCP.Cedaron.Interface.Declarations.IInterfaceReceiver.ReceiveLoop.AnonymousMethod__0(Cedaron.HL7.Client.HL7BlockingStream stream)
 	Cedaron.Interface.Engine.dll!Cedaron.Interface.Receivers.TCP.Cedaron.Interface.Declarations.IInterfaceReceiver.ReceiveLoop()
 	Cedaron.Interface.Engine.dll!Cedaron.Interface.Engine.Interface.ReceiveLoop()

.NET Server GC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET Server GC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET Debugger:
>	ntdll.dll!00007ff9df400d24()	Unknown
 	KERNELBASE.dll!00007ff9dc9d464c()	WaitForSingleObject
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET Server GC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET Server GC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET Event Pipe:
 	[Waiting on a lock, load symbols for ntdll.dll to show thread lock information]	
>	ntdll.dll!00007ff9df403cc4()	Unknown
 	ntdll.dll!00007ff9df379f09()	Unknown
 	ntdll.dll!00007ff9df3774c2()	Unknown
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET Server GC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET Server GC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET Server GC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET TP Worker:
 	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	[Managed to Native Transition]	
>	System.Private.CoreLib.dll!System.Threading.LowLevelLifoSemaphore.WaitForSignal(int timeoutMs) Line 140	C#
 	System.Private.CoreLib.dll!System.Threading.LowLevelLifoSemaphore.Wait(int timeoutMs, bool spinWait) Line 65	C#
 	System.Private.CoreLib.dll!System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() Line 100	C#

.NET BGC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET BGC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET BGC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET BGC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET BGC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET BGC:
>	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

.NET TP Worker:
 	ntdll.dll!00007ff9df400254()	Unknown
 	KERNELBASE.dll!00007ff9dc9ad71e()	WaitForMultipleObjects
 	[Managed to Native Transition]	
>	System.Private.CoreLib.dll!System.Threading.LowLevelLifoSemaphore.WaitForSignal(int timeoutMs) Line 140	C#
 	System.Private.CoreLib.dll!System.Threading.LowLevelLifoSemaphore.Wait(int timeoutMs, bool spinWait) Line 65	C#
 	System.Private.CoreLib.dll!System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() Line 100	C#
 	[Native to Managed Transition]	
 	kernel32.dll!00007ff9dde74cb0()	Unknown
 	ntdll.dll!00007ff9df3deceb()	Unknown

Reproduction Steps

No controlled reproduction available. We currently get the issue about three times per two weeks.

Expected behavior

new StringBuilder() does not hang forever.

Actual behavior

new StringBuilder() calls WaitForMultipleObjects, which does not return

Regression?

Yes; Issue is less than three months old.

Known Workarounds

No response

Configuration

.NET Runtime 8.0.7 via dotnet publish -r win-x64
OS: Windows Server Core; probably 2022

Other information

We have a full memory dump but can't release it publicly. This is a production instance and PHI is on the stack.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions