question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flaky test: `DataGridViewRow_PaintCells_Invoke_Success` deadlock

See original GitHub issue

Problem description:

Observing almost permanent test deadlocks locally and on build agents, especially after correcting test decorations in https://github.com/dotnet/winforms/pull/3064. Inspecting a memory dump of a locally hung test process I got the following:

image

 	System.Windows.Forms.Primitives.dll!Interop.User32.SendMessageW(IHandle hWnd = {System.Windows.Forms.DataGridView}, Interop.User32.WM Msg = CHANGEUISTATE, System.IntPtr wParam = 0x0000000000030001, System.IntPtr lParam = 0x0000000000000000) Line 36	C#	Symbols loaded.
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ShowFocusCues.get() Line 3710	C#	Symbols loaded.
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridViewTextBoxCell.PaintPrivate(System.Drawing.Graphics graphics = {System.Drawing.Graphics}, System.Drawing.Rectangle clipBounds = {X = 1 Y = 2 Width = 100 Height = 100}, System.Drawing.Rectangle cellBounds = {X = 42 Y = 2 Width = 100 Height = 100}, int rowIndex = 0, System.Windows.Forms.DataGridViewElementStates cellState = Displayed, object formattedValue = "", string errorText = "", System.Windows.Forms.DataGridViewCellStyle cellStyle = {System.Windows.Forms.DataGridViewCellStyle}, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle = {System.Windows.Forms.DataGridViewAdvancedBorderStyle}, System.Windows.Forms.DataGridViewPaintParts paintParts = All, bool computeContentBounds = false, bool computeErrorIconBounds = false, bool paint = true) Line 705	C#	Symbols loaded.
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridViewTextBoxCell.Paint(System.Drawing.Graphics graphics = {System.Drawing.Graphics}, System.Drawing.Rectangle clipBounds = {X = 1 Y = 2 Width = 100 Height = 100}, System.Drawing.Rectangle cellBounds = {X = 42 Y = 2 Width = 100 Height = 100}, int rowIndex = 0, System.Windows.Forms.DataGridViewElementStates cellState = Displayed, object value = null, object formattedValue = "", string errorText = "", System.Windows.Forms.DataGridViewCellStyle cellStyle = {System.Windows.Forms.DataGridViewCellStyle}, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle = {System.Windows.Forms.DataGridViewAdvancedBorderStyle}, System.Windows.Forms.DataGridViewPaintParts paintParts = All) Line 606	C#	Symbols loaded.
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridViewCell.PaintWork(System.Drawing.Graphics graphics = {System.Drawing.Graphics}, System.Drawing.Rectangle clipBounds = {X = 1 Y = 2 Width = 100 Height = 100}, System.Drawing.Rectangle cellBounds = {X = 42 Y = 2 Width = 100 Height = 100}, int rowIndex = 0, System.Windows.Forms.DataGridViewElementStates cellState = Displayed, System.Windows.Forms.DataGridViewCellStyle cellStyle = {System.Windows.Forms.DataGridViewCellStyle}, System.Windows.Forms.DataGridViewAdvancedBorderStyle advancedBorderStyle = {System.Windows.Forms.DataGridViewAdvancedBorderStyle}, System.Windows.Forms.DataGridViewPaintParts paintParts = All) Line 4287	C#	Symbols loaded.
 	System.Windows.Forms.dll!System.Windows.Forms.DataGridViewRow.PaintCells(System.Drawing.Graphics graphics = {System.Drawing.Graphics}, System.Drawing.Rectangle clipBounds = {X = 1 Y = 2 Width = 100 Height = 100}, System.Drawing.Rectangle rowBounds = {X = 1 Y = 2 Width = 100 Height = 100}, int rowIndex = 0, System.Windows.Forms.DataGridViewElementStates rowState = Displayed, bool isFirstDisplayedRow = true, bool isLastVisibleRow = false, System.Windows.Forms.DataGridViewPaintParts paintParts = All) Line 1617	C#	Symbols loaded.
>	System.Windows.Forms.Tests.dll!System.Windows.Forms.Tests.DataGridViewRowTests.DataGridViewRow_PaintCells_Invoke_Success(System.Windows.Forms.DataGridViewRow row = {System.Windows.Forms.DataGridViewRow}, System.Drawing.Rectangle clipBounds = {X = 1 Y = 2 Width = 100 Height = 100}, System.Drawing.Rectangle rowBounds = {X = 1 Y = 2 Width = 100 Height = 100}, int rowIndex = 0, System.Windows.Forms.DataGridViewElementStates rowState = Displayed, bool isFirstDisplayedRow = true, bool isLastVisibleRow = false, System.Windows.Forms.DataGridViewPaintParts paintParts = All) Line 3263	C#	Symbols loaded.

There doesn’t appear any other threads with code from System.Windows.Forms, so it looks like this code deadlocks on itself.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

3reactions
AArnottcommented, May 5, 2020

So if I understand correctly, an [StaTheory] test has a data-generating attribute whose method is running but not on the same STA thread that the test runs on? I’d never considered that requirement but it makes sense to fix this. I don’t know whether xunit even gives the discovery attribute power to execute the data generating attribute. If so, I can fix this.

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.

1reaction
weltkantecommented, May 5, 2020

Thread IDs are consistent now, so as far as I can tell it works. Test also doesn’t hang.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found