Tools

Diagnosing an async deadlock with dotnet-dump and an AI agent

Gérald Barré (Meziantou's blog) Gérald Barré
Tools

A hang with zero CPU use that no monitor explains: the main thread blocks on .Result while the continuation waits in a SynchronizationContext queue nobody pumps. The author walks a dotnet-dump investigation and shows which commands force an AI agent to prove the diagnosis.

Key points

  • The sample installs a single-threaded SynchronizationContext and blocks on GetCustomerAsync(1001).Result, so the process never returns.
  • Collect a Full dump with dotnet-dump collect; dumpobj prints field values only for Full dumps.
  • parallelstacks shows five threads: one in Task.GetResultCore and two idle workers in LowLevelLifoSemaphore.WaitForSignal.
  • syncblk prints nothing, which rules out a monitor deadlock; dumpasync then shows the state machine still at its first await.
  • dumpheap and dumpobj locate the context, and dumpconcurrentqueue reveals the queued callback that never runs.
  • Fix with await, or ConfigureAwait(false) inside the library when the blocking call cannot be removed.

Real-world use

  • WinForms, WPF, MAUI or legacy ASP.NET apps that install a single-threaded SynchronizationContext.
  • A production process that hangs with no CPU usage and needs a dump taken inside a container (--cap-add=SYS_PTRACE).
  • A library that cannot change its callers, where ConfigureAwait(false) makes this deadlock disappear.

This summary was generated by the agent from the original post on Gérald Barré (Meziantou's blog). The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message