deadlockdetection icon indicating copy to clipboard operation
deadlockdetection copied to clipboard

SynchronizationContext is reset after first await

Open slang25 opened this issue 8 years ago • 4 comments

I've been testing in ASP.NET and have spotted what I think is a pretty big bug.

When I await for the first time, the continuation runs with the AspNetSynchronizationContext not the expected DeadlockDetectionSynchronizationContext, so I can only detect deadlocks in a small subset of situations.

Thankfully it appears that this can be fixed by using Delegate.Combine, SetSynchronizationContext(this) and the SendOrPostCallback d parameter in the Post method. I need to do some further investigation to see if this is specific to just ASP.NET and if I need to also implement this in the Send method.

Except a PR regarding this in the next few days.

slang25 avatar Apr 16 '17 20:04 slang25

@slang25 did you ever do that PR?

glenthomas avatar Aug 24 '18 13:08 glenthomas

No, I have never received a follow-up from @slang25 and I don’t really know what the solution is. I hope he will submit a pull request.

ramondeklein avatar Aug 25 '18 09:08 ramondeklein

Hello, I did make a start a few months ago, but got myself into a bit of a muddle with it, I'll make another take at it tomorrow and let you know how I get on.

slang25 avatar Aug 25 '18 20:08 slang25

I've submitted a PR that fixes this: https://github.com/ramondeklein/deadlockdetection/pull/5

Bouke avatar Dec 10 '20 16:12 Bouke