-
Notifications
You must be signed in to change notification settings - Fork 982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests deadlock #1999
Comments
Few questions here:
/cc: @hughbe |
Creating a control handle on a non-STA thread is a bad idea, it turns the thread pool thread into a UI thread by allocating a message queue etc. but without telling COM that the thread is STA, so controls using COM internally (e.g. RichTextBox) will be pretty confused, if working at all. |
I think |
@JeremyKuhne do you know if |
/cc: @AArnott any thoughts on the subject? |
Could it be that we don’t dispose any controls in the unit tests? |
I think there are multiple concerns here The deadlock @RussKie shows is probably just a bug in the NoAssertListener, the TraceListenerCollection has its own lock. I didn't do a full analysis but it looks like you got a lock inversion with the NoAssertListeners lock: one path takes them in order A B the other code path takes them in order B A, leading to a deadlock. Then there is the whole concern of running tests involving window handles and OLE interop on non-STA threads, which technically is not part of this issue, I just was asking here because people already were discussing the test attributes after my first comment. Not disposing a control may be a problem, but its not directly related to the deadlock. My first comment about control handle creation was just a general comment without having looked at the problem in detail, sorry for leading the discussion astray. I still think the whole STA/OLE initialization needs to be examined though, maybe in context of some of the other issues about unstable tests. |
The |
The assert context listener would deadlock sometimes and wasn't particularly efficient. @weltkante discovered this in dotnet#2184 and encouraged me to rethink how to approach this. Also disable flaky test `Application_VisualStyleState_Set_ReturnsExpected` that also leads to deadlocks. Fixes dotnet#1999
Problem description:
Running tests from the master branch locally I got tests hung. I have attached a debugger and there was a dozen of hung threads.
9 threads were stuck unable to acquire the lock in
NativeWindow.CreateHandle()
method (originating stacks were slightly different, but they all ended in the same critical section):1 thread was stuck restoring the default trace listener:
2 thread were stuck while writing a trace:
What appears to have happened is that one test was in a middle of creating a handle and attempted to add a trace, which was locked by another thread, that was restoring the default trace listener:
Expected behavior:
No deadlock
Minimal repro:
This is very intermittent...
The text was updated successfully, but these errors were encountered: