Skip to content

derekchristensen/DeadlockSample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

System.CommandLine Deadlock Sample

System.CommandLine v2.0.0-beta1.21216.1

This project demonstrates a deadlock condition in the System.CommandLine library. Based on my debugging the deadlock happens when a command handler is returning and the Ctrl+C handler is trying to detach the event handler on the Console.CancelKeyPress event handler. It appears to lock the thread when trying to detach the handler. The issue seems to be dependent on an assembly being loaded via Assembly.LoadFile.

Reproduction

> cd .\bin
> .\DeadlockSample.exe

Once prompted press Ctrl+C to trigger the deadlock:

> .\DeadlockSample.exe
Press Ctrl+C to exit...
System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at DeadlockSample.MyApp.<Run>d__0.MoveNext() in C:\dev\tmp\DeadlockSample\DeadlockSample.MyApp\MyApp.cs:line 15

The app does not exit as expected.

Stack traces of the deadlocked state:

Worker Thread Callstack

Main Thread Callstack

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published