-
Notifications
You must be signed in to change notification settings - Fork 953
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
Flaky test: DataGridViewRow_PaintCells_Invoke_Success
deadlock
#3209
Comments
Ouch, that is a bad hang. Looks like its waiting for a control on a thread without message loop. Now I'm wondering whether test data is generated on a separate thread. If so that would be a major problem for creating any thread-bound object in test data because it can make any test flaky /cc @hughbe FYI I'll start passing the ThreadID through the test data arguments and assert that the tests run on the same thread as the objects were created on. |
Yup thats the problem, test data is generating thread bound objects on a different thread. We probably need a @AArnott @RussKie is this something we'd also want propagated back into Xunit.StaFact, or should we start creating local test infrastructure instead considering that we can't use the nuget package anyways due to #3122 ? @hughbe this particular test data is also breaking other rules because it shares a DataGridView over multiple test data rows and never disposes the actual control, so even after fixing the thread test data is created on these tests will still leak DataGridView controls, risking deadlocks in other tests. |
Yes unfortunately these tests were designed pretty badly. I'm working on a full overhaul by removing |
So if I understand correctly, an Even if you fork my project and/or use a git submodule, etc., I'd love to keep the code as similar between our codebases as possible. This is an example of good stuff you're finding that our customers who want to test WinForms will likely also hit. |
OK, so I did some digging. There appears to be no way we can ensure the data objects are created on the STA thread. In fact when running in the Test Explorer, they weren't created at all -- they were deserialized. The data generating attribute ran out of proc and its results had been serialized, only to be reconstituted later in the test executing process. I wasn't testing with thread-affinitized data objects, and I have no idea how this would work with objects that can't theoretically be serialized. But suffice it to say, xunit calls the data generating attributes before ever getting to my xunit.stafact code. So I don't think there's anything I can do. |
sure, just asking if there is interest in flowing this back, I can open an issue with a repro scenario over at the StaFact repo, debugging the winforms tests is still a pain until some of the other issues here get fixed :-) [edit] sorry didn't see your second response before writing mine
I need to be debugging this, but considering that you can generate non-serializable objects in test data this seems weird. I had debugged this recently for #3122 to make sure my workarounds actually work, and I don't think the data items get deserialized (I may be mistaken of course).
I'll take a closer look myself later today and we'll see if I come to the same conclusion. Thanks for doing a quick check though. |
Ok, good news. I created a custom type and return it in my The best news is that xunit.stafact does control the thread that this in-proc re-generation of data runs on:
So I'll file a bug and see if we can get this fixed. |
Can someone download the build artifact from this PR build and validate that it resolves your issue? |
This comment has been minimized.
This comment has been minimized.
Thread IDs are consistent now, so as far as I can tell it works. Test also doesn't hang. |
Thanks for the validation. This is now pushed to nuget. https://github.com/AArnott/Xunit.StaFact/releases/tag/v1.0.31-beta |
great, thanks again for looking into it! (for the record, this is blocked on #3122 because fixes in stafact currently cannot flow to winforms, I used the workaround mentioned in the issue to test locally) |
#3122 is high on my list, I just have a massive backlog do deal with |
Yes, thank you for keeping track of this 👍 |
Problem description:
Observing almost permanent test deadlocks locally and on build agents, especially after correcting test decorations in #3064.
Inspecting a memory dump of a locally hung test process I got the following:
There doesn't appear any other threads with code from System.Windows.Forms, so it looks like this code deadlocks on itself.
The text was updated successfully, but these errors were encountered: