Skip to content
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 tests: ImageList randomly crashes tests and result in AccessViolationException #3358

Closed
RussKie opened this issue May 28, 2020 · 68 comments · Fixed by #3526 or #3601
Closed

Flaky tests: ImageList randomly crashes tests and result in AccessViolationException #3358

RussKie opened this issue May 28, 2020 · 68 comments · Fixed by #3526 or #3601
Assignees
Labels
test-bug Problem in test source code (most likely)

Comments

@RussKie
Copy link
Member

RussKie commented May 28, 2020

For the past few days I'm observing tests randomly fail in Release builds, with some builds providing no logs of failures.
Few other logs I found are below:

    System.Windows.Forms.Tests.ImageCollectionTests.ImageCollection_IListItem_Set_GetReturnsExpected(transparentColor: Color [Empty], value: Bitmap { Flags = 2, FrameDimensionsList = [7462dc86-6180-4c7e-8e3f-ee7333a7a483], Height = 256, HorizontalResolution = 96, Palette = ColorPalette { Entries = [...], Flags = 7929940 }, ... }) [FAIL]
      System.InvalidOperationException : Image cannot be added to the ImageList.
      Stack Trace:
        /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs(414,0): at System.Windows.Forms.ImageList.AddToHandle(Bitmap bitmap)
        /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs(485,0): at System.Windows.Forms.ImageList.CreateHandle()
        /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs(142,0): at System.Windows.Forms.ImageList.get_Handle()
        /_/src/System.Windows.Forms.Primitives/src/Interop/ComCtl32/Interop.ImageList.Replace.cs(20,0): at Interop.ComCtl32.ImageList.Replace(IHandle himl, Int32 i, IntPtr hbmImage, IntPtr hbmMask)
        /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs(166,0): at System.Windows.Forms.ImageList.ImageCollection.set_Item(Int32 index, Image value)
        /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs(199,0): at System.Windows.Forms.ImageList.ImageCollection.System.Collections.IList.set_Item(Int32 index, Object value)
        /_/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ImageList.ImageCollectionTests.cs(1626,0): at System.Windows.Forms.Tests.ImageCollectionTests.ImageCollection_IListItem_Set_GetReturnsExpected(Color transparentColor, Image value)
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
--------------------------------
   at Interop+User32.CallWindowProcW(IntPtr, IntPtr, WM, IntPtr, IntPtr)
--------------------------------
   at System.Windows.Forms.NativeWindow.DefWndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.DefWndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ListView.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr, WM, IntPtr, IntPtr)
   at Interop+User32.SendMessageW(IntPtr, WM, IntPtr, IntPtr)
   at Interop+User32.SendMessageW(IntPtr, WM, IntPtr, IntPtr)
   at Interop+User32.SendMessageW(IHandle, WM, IntPtr, IntPtr)
   at System.Windows.Forms.ListView.UpdateExtendedStyles()
   at System.Windows.Forms.ListView.OnHandleCreated(System.EventArgs)
   at System.Windows.Forms.Control.WmCreate(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ListView.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr, WM, IntPtr, IntPtr)
   at Interop+User32.CreateWindowExW(WS_EX, Char*, System.String, WS, Int32, Int32, Int32, Int32, IntPtr, IntPtr, IntPtr, System.Object)
   at Interop+User32.CreateWindowExW(WS_EX, Char*, System.String, WS, Int32, Int32, Int32, Int32, IntPtr, IntPtr, IntPtr, System.Object)
   at Interop+User32.CreateWindowExW(WS_EX, System.String, System.String, WS, Int32, Int32, Int32, Int32, IntPtr, IntPtr, IntPtr, System.Object)
   at System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreateParams)
   at System.Windows.Forms.Control.CreateHandle()
   at System.Windows.Forms.ListView.CreateHandle()
   at System.Windows.Forms.Control.get_Handle()
   at System.Windows.Forms.Tests.ListViewTests.ListView_StateImageList_SetWithHandle_GetReturnsExpected(Boolean, Boolean, Boolean, Boolean, System.Windows.Forms.View, System.Windows.Forms.ImageList, Int32, Int32)
   at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean, Boolean)
   at System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Reflection.MethodBase.Invoke(System.Object, System.Object[])
   at Xunit.Sdk.TestInvoker`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].CallTestMethod(System.Object)
   at Xunit.Sdk.UITestInvoker+<>c__DisplayClass2_0+<<RunAsync>b__2>d.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Xunit.Sdk.UITestInvoker+<>c__DisplayClass2_0+<<RunAsync>b__2>d, Xunit.StaFact, Version=1.0.0.0, Culture=neutral, PublicKeyToken=593f35978b459a4b]].ExecutionContextCallback(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Xunit.Sdk.UITestInvoker+<>c__DisplayClass2_0+<<RunAsync>b__2>d, Xunit.StaFact, Version=1.0.0.0, Culture=neutral, PublicKeyToken=593f35978b459a4b]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Xunit.Sdk.UITestInvoker+<>c__DisplayClass2_0+<<RunAsync>b__2>d, Xunit.StaFact, Version=1.0.0.0, Culture=neutral, PublicKeyToken=593f35978b459a4b]].MoveNext()
   at Xunit.Sdk.Utilities+SyncContextAwaiter+<>c.<OnCompleted>b__5_0(System.Object)
   at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean, Boolean)
   at System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
   at System.Delegate.DynamicInvokeImpl(System.Object[])
   at System.Delegate.DynamicInvoke(System.Object[])
   at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr, WM, IntPtr, IntPtr)
   at Interop+User32.DispatchMessageW(MSG ByRef)
   at Interop+User32.DispatchMessageW(MSG ByRef)
   at System.Windows.Forms.Application+ComponentManager.Interop.Mso.IMsoComponentManager.FPushMessageLoop(UIntPtr, msoloop, Void*)
   at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(msoloop, System.Windows.Forms.ApplicationContext)
   at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(msoloop, System.Windows.Forms.ApplicationContext)
   at Xunit.Sdk.WinFormsSynchronizationContextAdapter.PumpTill(System.Threading.SynchronizationContext, System.Threading.Tasks.Task)
   at Xunit.Sdk.ThreadRental+<>c__DisplayClass11_0.<CreateAsync>b__0()
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()
@RussKie RussKie changed the title Flaky tests: ImageCollection_IListItem_Set_GetReturnsExpected result in AccessViolationException Flaky tests: ImageList randomly crashes tests and result in AccessViolationException May 28, 2020
@RussKie RussKie added the test-bug Problem in test source code (most likely) label May 28, 2020
@weltkante
Copy link
Contributor

weltkante commented May 28, 2020

If you want to get minidumps on crashes there is a registry setting for that you could set in a powershell script, but its probably all just AccessViolations after some memory corruption so the stack traces probably won't be too useful. (If an AccessViolation happens outside managed code then it just terminates the process.)

I'll update my master branch and see if these are reproducable locally.

@RussKie
Copy link
Member Author

RussKie commented May 28, 2020

I'll try to get some time to plugin the screenshot capture and a memory dump functionality into the CI pipeline.

@RussKie RussKie self-assigned this May 28, 2020
@weltkante
Copy link
Contributor

Not getting any AVs or process crashes locally.

@RussKie
Copy link
Member Author

RussKie commented May 29, 2020

Some more: https://dev.azure.com/dnceng/public/_build/results?buildId=662467&view=artifacts&type=publishedArtifacts

    System.Windows.Forms.Tests.ImageCollectionTests.ImageCollection_AddStrip_InvokeWithHandle_Success(transparentColor: Color [Black], value: Bitmap { Flags = 2, FrameDimensionsList = [7462dc86-6180-4c7e-8e3f-ee7333a7a483], Height = 16, HorizontalResolution = 96, Palette = ColorPalette { Entries = [...], Flags = 85653360 }, ... }, expectedCount: 1) [FAIL]
      System.InvalidOperationException : Image cannot be added to the ImageList.
      Stack Trace:
        F:\workspace\_work\1\s\src\System.Windows.Forms\src\System\Windows\Forms\ImageList.cs(414,0): at System.Windows.Forms.ImageList.AddToHandle(Bitmap bitmap)
        F:\workspace\_work\1\s\src\System.Windows.Forms\src\System\Windows\Forms\ImageList.ImageCollection.cs(336,0): at System.Windows.Forms.ImageList.ImageCollection.Add(Original original, ImageInfo imageInfo)
        F:\workspace\_work\1\s\src\System.Windows.Forms\src\System\Windows\Forms\ImageList.ImageCollection.cs(427,0): at System.Windows.Forms.ImageList.ImageCollection.AddStrip(Image value)
        F:\workspace\_work\1\s\src\System.Windows.Forms\tests\UnitTests\System\Windows\Forms\ImageList.ImageCollectionTests.cs(881,0): at System.Windows.Forms.Tests.ImageCollectionTests.ImageCollection_AddStrip_InvokeWithHandle_Success(Color transparentColor, Image value, Int32 expectedCount)

One thing I didn't notice before, only x86 tests appear to fail, which suggests bitness-related issues.

@merriemcgaw merriemcgaw added this to the 5.0 milestone Jun 4, 2020
@RussKie
Copy link
Member Author

RussKie commented Jun 5, 2020

Another IOE in Release x64:

    System.Windows.Forms.Tests.ImageCollectionTests.ImageCollection_AddStrip_InvokeWithHandle_Success(transparentColor: Color [Black], value: Bitmap { Flags = 2, FrameDimensionsList = [7462dc86-6180-4c7e-8e3f-ee7333a7a483], Height = 16, HorizontalResolution = 96, Palette = ColorPalette { Entries = [...], Flags = 6619213 }, ... }, expectedCount: 2) [FAIL]
      System.InvalidOperationException : Image cannot be added to the ImageList.
      Stack Trace:
        /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs(414,0): at System.Windows.Forms.ImageList.AddToHandle(Bitmap bitmap)
        /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs(336,0): at System.Windows.Forms.ImageList.ImageCollection.Add(Original original, ImageInfo imageInfo)
        /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.ImageCollection.cs(427,0): at System.Windows.Forms.ImageList.ImageCollection.AddStrip(Image value)
        /_/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ImageList.ImageCollectionTests.cs(857,0): at System.Windows.Forms.Tests.ImageCollectionTests.ImageCollection_AddStrip_InvokeWithHandle_Success(Color transparentColor, Image value, Int32 expectedCount)

https://dev.azure.com/dnceng/public/_build/results?buildId=672867&view=results

@weltkante
Copy link
Contributor

I had that same ImageCollection_AddStrip_InvokeWithHandle_Success test fail locally reporting that AddStrip loaded zero images (expected one image)

These failures make no sense, makes memory corruption the most likely cause.

@hughbe
Copy link
Contributor

hughbe commented Jun 7, 2020

Also failure in ImageCollection_IListItem_SetWithHandle_GetReturnsExpected

System.InvalidOperationException : Image cannot be added to the ImageList.
   at System.Windows.Forms.ImageList.AddToHandle(Bitmap bitmap) in /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs:line 414
   at System.Windows.Forms.ImageList.CreateHandle() in /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs:line 485
   at System.Windows.Forms.ImageList.get_Handle() in /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs:line 142
   at System.Windows.Forms.Tests.ImageCollectionTests.ImageCollection_IListItem_SetWithHandle_GetReturnsExpected(Color transparentColor, Image value) in /_/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ImageList.ImageCollectionTests.cs:line 1705

@RussKie
Copy link
Member Author

RussKie commented Jun 9, 2020

I can't seem to repro this issue locally...
Looking through the code all tests appear to be failing at the same point - System.Windows.Forms.ImageList.AddToHandle(Bitmap bitmap) in /_/src/System.Windows.Forms/src/System/Windows/Forms/ImageList.cs:line 414.

I think it fails here:

try
{
index = ComCtl32.ImageList.Add(this, hBitmap, hMask);
}
finally
{
Gdi32.DeleteObject(hBitmap);
Gdi32.DeleteObject(hMask);
}
if (index == -1)
{
throw new InvalidOperationException(SR.ImageListAddFailed);
}

If I found the right code for ImageList_Add then it's failing while invoking HIMAGELIST_QueryInterface on the supplied imagelist, and failing returns -1.

@hughbe
Copy link
Contributor

hughbe commented Jun 9, 2020

This is really weird. I know its not related to your theory here, but could @weltkante's comment here #3324 (comment) cause this?

Perhaps there's some odd/incorrect/overlapping memory copying happening?

@weltkante
Copy link
Contributor

weltkante commented Jun 9, 2020

I really doubt its a bug in the native ImageList implementation itself, QueryInterface failing would mean the object is corrupted (playing into the memory corruption idea) or already released (which I'd expect to be handled gracefully returning an error, e.g. the image list handle should also be invalid and have immediately complained about that).

but could @weltkante's comment here #3324 (comment) cause this?

Perhaps there's some odd/incorrect/overlapping memory copying happening?

Sure, you can cause arbitrary damage by bad memory copying. But I don't think that particular linked comment was right, later in the discussion it became clear that the caller made/provided a lot of assumptions that should have made the code safe.

I can't seem to repro this issue locally

I had some locally, but very rare (one in several dozen runs), and never under a debugger. I think the best chance is getting some dumps (probably need a full dump though not a minidump). I'll look into what options we have, I don't think we can set the usual machine wide setting to capture dumps on process crash, so to trigger a dump being written we might need some native DLL stub to write out the dump (SetUnhandledExceptionFilter/MiniDumpWriteDump), or a secondary helper process.

@RussKie
Copy link
Member Author

RussKie commented Jun 9, 2020

@MattGal we seem to have "progressed" to level 2 of test nightmares, tests randomly fail with no clear indication of the underlying cause.
Is collecting user-mode memory dumps a possibility on CI agents (it requires HKLM registry settings)?

@RussKie RussKie added the Priority:0 Work that we can't release without label Jun 9, 2020
@RussKie
Copy link
Member Author

RussKie commented Jun 9, 2020

Looking at a log for a failed build in #3224 (comment) it appears we may have a a minidump (snip):

      Timed out at 6/9/2020 11:12:41 AM after 60000ms waiting for remote process.
      Wrote mini dump to: F:\h\w\B5E80973\w\AB98096F\uploads\5272.aw55rizx.gmv.dmp
      	Process ID: 5272
      	Handle: 10236
      	Name: dotnet
      	MainModule: F:\workspace\_work\1\s\.dotnet\dotnet.exe
      	Threads:
      		Thread #1 (OS 0x868)   
      			[InlinedCallFrame]
      			[InlinedCallFrame]
      			System.Environment.Exit(Int32)
      			Microsoft.DotNet.RemoteExecutor.Program.Main(System.String[])
      		Thread #2 (OS 0x16CC) [Finalizer] [Background] 
      			(...snip...)
      		Thread #3 (OS 0x12F8) [Thread pool worker] [Background] [MTA]
      		Thread #5 (OS 0x1A94)  [Background] 
      			(...snip...)
      		Thread #4 (OS 0x7CB4) [Thread pool worker] [Background] [MTA]
      		Thread #6 (OS 0x8BF4) [Thread pool worker] [Background] [MTA]
      
      Stack Trace:
        /_/src/Microsoft.DotNet.RemoteExecutor/src/RemoteInvokeHandle.cs(219,0): at Microsoft.DotNet.RemoteExecutor.RemoteInvokeHandle.Dispose(Boolean disposing)
        /_/src/Microsoft.DotNet.RemoteExecutor/src/RemoteInvokeHandle.cs(54,0): at Microsoft.DotNet.RemoteExecutor.RemoteInvokeHandle.Dispose()
        F:\workspace\_work\1\s\src\System.Windows.Forms\tests\UnitTests\AccessibleObjects\ListViewGroupAccessibleObjectTests.cs(142,0): at System.Windows.Forms.Tests.AccessibleObjects.ListViewGroupAccessibleObjectTests.ListViewGroupAccessibleObject_Bounds_ReturnsCorrectValue()

A question is whether we get a mini dump when a test runner crashes.

@hughbe
Copy link
Contributor

hughbe commented Jun 9, 2020

Microsoft.DotNet.RemoteExecutor.Program.Main

I thought RemoteExecutor is disabled in winforms?

@RussKie
Copy link
Member Author

RussKie commented Jun 9, 2020

I thought RemoteExecutor is disabled in winforms?

We disabled it, but this is a new test being developed that hasn't been skipped.
I've actually wondered whether we could re-enable RE, but apparently not :(

@weltkante
Copy link
Contributor

weltkante commented Jun 9, 2020

Do you have access to it? Its not in the artifact zip you can publically download (it just has log and binlog files). Also its not guaranteed that there will be any relation to this issue, RemoteExecutor is likely to be different failures than this (still worth to examine and fix of course)

On second thought the dump probably will just say the process is waiting for RemoteExecutor (separate process), probably not much use, sorry to get your hopes up.

@weltkante
Copy link
Contributor

weltkante commented Jun 9, 2020

A question is whether we get a mini dump when a test runner crashes.

no, not with the existing tooling, you need to let the OS take a dump or insert your own code in SetUnhandledExceptionHandler. I'm not aware of other notifications that a process crashed, maybe powershell has some hook to be notified of crashes in processes it started, but I doubt it. Dumps taken on a timeout are only helpful for hangs.

@weltkante
Copy link
Contributor

weltkante commented Jun 9, 2020

Turned on the dump collection flags locally and have been repeating testruns for a few hours, but I got a full crash dump now. No entry in log but the crashing test is List​View_State​Image​List_Set​With​Handle​With​Non​Null​Old​Value_Get​Returns​Expected, panic crash due to memory corruption, so yeah my guess was probably right.

error/stacktrace

Unhandled exception at 0x77A1FA1D (ntdll.dll) in CrashWithEmptyLog.dmp: 0xC0000374: A heap has been corrupted (parameters: 0x77A5B960).

 	ntdll.dll!_RtlReportFatalFailure@4�()	Unknown
 	ntdll.dll!_RtlReportCriticalFailure@12�()	Unknown
 	ntdll.dll!_RtlpReportHeapFailure@4�()	Unknown
 	ntdll.dll!_RtlpHpHeapHandleError@12�()	Unknown
 	ntdll.dll!_RtlpLogHeapFailure@24�()	Unknown
 	ntdll.dll!_RtlpFreeHeapInternal@20�()	Unknown
 	ntdll.dll!RtlFreeHeap()	Unknown
 	comctl32.dll!operator delete(void *)	Unknown
 	comctl32.dll!CImageList::`scalar deleting destructor'(unsigned int)	Unknown
 	comctl32.dll!CImageList::Release(void)	Unknown
 	comctl32.dll!_ImageList_AddMasked@12�()	Unknown
 	comctl32.dll!_CreateCheckBoxImagelist@16�()	Unknown
 	comctl32.dll!_ListView_InitCheckBoxes@8�()	Unknown
 	comctl32.dll!_ListView_ExtendedStyleChange@12�()	Unknown
 	comctl32.dll!_ListView_WndProc@16�()	Unknown
 	user32.dll!__InternalCallWinProc@20�()	Unknown
 	user32.dll!UserCallWinProcCheckWow()	Unknown
 	user32.dll!CallWindowProcW()	Unknown
 	[Managed to Native Transition]	
>	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DefWndProc(ref System.Windows.Forms.Message m) Line 515	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.DefWndProc(ref System.Windows.Forms.Message m) Line 5047	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Line 13211	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ListView.WndProc(ref System.Windows.Forms.Message m) Line 6626	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Line 67	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Line 119	C#
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, Interop.User32.WM msg, System.IntPtr wparam, System.IntPtr lparam) Line 372	C#
 	[Native to Managed Transition]	
 	user32.dll!__InternalCallWinProc@20�()	Unknown
 	user32.dll!UserCallWinProcCheckWow()	Unknown
 	user32.dll!SendMessageWorker()	Unknown
 	user32.dll!SendMessageW()	Unknown
 	[Managed to Native Transition]	
 	System.Windows.Forms.Primitives.dll!Interop.User32.SendMessageW(IHandle hWnd, Interop.User32.WM Msg, System.IntPtr wParam, System.IntPtr lParam) Line 36	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ListView.UpdateExtendedStyles() Line 5415	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ListView.OnHandleCreated(System.EventArgs e) Line 4364	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WmCreate(ref System.Windows.Forms.Message m) Line 11980	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Line 12990	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ListView.WndProc(ref System.Windows.Forms.Message m) Line 6626	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Line 67	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Line 119	C#
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, Interop.User32.WM msg, System.IntPtr wparam, System.IntPtr lparam) Line 372	C#
 	[Native to Managed Transition]	
 	user32.dll!__InternalCallWinProc@20�()	Unknown
 	user32.dll!UserCallWinProcCheckWow()	Unknown
 	user32.dll!DispatchClientMessage()	Unknown
 	user32.dll!__fnINLPCREATESTRUCT()	Unknown
 	ntdll.dll!_KiUserCallbackDispatcher@12�()	Unknown
 	user32.dll!CreateWindowInternal()	Unknown
 	user32.dll!_CreateWindowExW@48�()	Unknown
 	[Managed to Native Transition]	
 	System.Windows.Forms.Primitives.dll!Interop.User32.CreateWindowExW(Interop.User32.WS_EX dwExStyle, string lpClassName, string lpWindowName, Interop.User32.WS dwStyle, int X, int Y, int nWidth, int nHeight, System.IntPtr hWndParent, System.IntPtr hMenu, System.IntPtr hInst, object lpParam) Line 43	C#
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreateParams cp) Line 460	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.CreateHandle() Line 4941	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ListView.CreateHandle() Line 2481	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.RecreateHandleCore() Line 9766	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.RecreateHandle() Line 9688	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ListView.RecreateHandleInternal() Line 6059	C#
 	System.Windows.Forms.dll!System.Windows.Forms.ListView.StateImageList.set(System.Windows.Forms.ImageList value) Line 1618	C#
 	System.Windows.Forms.Tests.dll!System.Windows.Forms.Tests.ListViewTests.ListView_StateImageList_SetWithHandleWithNonNullOldValue_GetReturnsExpected(bool useCompatibleStateImageBehavior, bool checkBoxes, bool autoArrange, bool virtualMode, System.Windows.Forms.View view, System.Windows.Forms.ImageList value, int expectedInvalidatedCallCount, int expectedCreatedCallCount) Line 3482	C#
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	xunit.execution.dotnet.dll!Xunit.Sdk.TestInvoker<System.__Canon>.CallTestMethod(object testClassInstance) Line 150	C#
 	Xunit.StaFact.dll!Xunit.Sdk.UITestInvoker.RunAsync.AnonymousMethod__2()	Unknown
 	[Resuming Async Method]	
 	System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<Xunit.Sdk.UITestInvoker.ExecutionContextCallback(object s) Line 291	C#
 	System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 172	C#
 	System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<Xunit.Sdk.UITestInvoker.MoveNext(System.Threading.Thread threadPoolThread) Line 329	C#
 	System.Private.CoreLib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>.AsyncStateMachineBox<Xunit.Sdk.UITestInvoker.MoveNext() Line 307	C#
 	Xunit.StaFact.dll!Xunit.Sdk.Utilities.SyncContextAwaiter.OnCompleted.AnonymousMethod__5_0(object s)	Unknown
 	[Native to Managed Transition]	
 	[Managed to Native Transition]	
 	System.Private.CoreLib.dll!System.Delegate.DynamicInvokeImpl(object[] args) Line 89	C#
 	System.Private.CoreLib.dll!System.Delegate.DynamicInvoke(object[] args) Line 61	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme) Line 6512	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj) Line 6469	C#
 	System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 172	C#
 	System.Private.CoreLib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 132	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback(System.Windows.Forms.Control.ThreadMethodEntry tme) Line 6446	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks() Line 6550	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Line 13191	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) Line 67	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) Line 119	C#
 	System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(System.IntPtr hWnd, Interop.User32.WM msg, System.IntPtr wparam, System.IntPtr lparam) Line 372	C#
 	[Native to Managed Transition]	
 	user32.dll!__InternalCallWinProc@20�()	Unknown
 	user32.dll!UserCallWinProcCheckWow()	Unknown
 	user32.dll!DispatchMessageWorker()	Unknown
 	user32.dll!_DispatchMessageW@4�()	Unknown
 	[Managed to Native Transition]	
 	System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.Interop.Mso.IMsoComponentManager.FPushMessageLoop(System.UIntPtr dwComponentID, Interop.Mso.msoloop uReason, void* pvLoopData) Line 345	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Interop.Mso.msoloop reason, System.Windows.Forms.ApplicationContext context) Line 1130	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Interop.Mso.msoloop reason, System.Windows.Forms.ApplicationContext context) Line 992	C#
 	System.Windows.Forms.dll!System.Windows.Forms.Application.DoEvents() Line 811	C#
 	Xunit.StaFact.dll!Xunit.Sdk.WinFormsSynchronizationContextAdapter.PumpTill(System.Threading.SynchronizationContext synchronizationContext, System.Threading.Tasks.Task task)	Unknown
 	Xunit.StaFact.dll!Xunit.Sdk.ThreadRental.CreateAsync.AnonymousMethod__0()	Unknown
 	System.Private.CoreLib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) Line 49	C#
 	System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 172	C#
 	System.Private.CoreLib.dll!System.Threading.ThreadHelper.ThreadStart() Line 99	C#
 	[Native to Managed Transition]	
 	kernel32.dll!@BaseThreadInitThunk@12�()	Unknown
 	ntdll.dll!__RtlUserThreadStart()	Unknown
 	ntdll.dll!__RtlUserThreadStart@8�()	Unknown

Now the hard part will be figuring out what could be causing the corruption 😓 I'll be digging around a bit in the dump in hope the offender isn't already long gone.

[edit] not much I can gather from a sample size of one dump, but there are surprisingly few tests running compared to other dumps I've seen; don't have time for further test runs today but I guess I'll keep running and gathering dumps over the next few days, if I can get a few different of these failures we may be able to cross relate which tests are running in each

Still running:

  • System​.Windows​.Forms​.Tests​.ListViewTests​.List​View​_State​Image​List​_Set​With​Handle​With​Non​Null​Old​Value​_Get​Returns​Expected
  • System​.Windows​.Forms​.Tests​.WebBrowserTests​.WebBrowser​_Refresh​_Invoke​Web​Browser​Refresh​Option​With​Document​Text​_Success
  • System​.Windows​.Forms​.Tests​.Html​Document​Tests​.Html​Document​_Link​Color​_Get​Custom​Value​On​Body​_Returns​Expected
  • all other are are either starting up the thread or waiting to create their first handle, so most likely have not performed any interop yet

Recently terminated:

  • System​.Windows​.Forms​.Tests​.Tool​Strip​Tests​.Tool​Strip​_Default​Drop​Down​Direction​_Get​Design​Mode​With​Tool​Strip​Panel​Parent​_Returns​Expected
  • all other are already gone

@MattGal
Copy link
Member

MattGal commented Jun 9, 2020

@MattGal we seem to have "progressed" to level 2 of test nightmares, tests randomly fail with no clear indication of the underlying cause.
Is collecting user-mode memory dumps a possibility on CI agents (it requires HKLM registry settings)?

Not only is it a possibility, we've already done it for you! In fact for the run in question I think this is a dump... doesn't seem to have your specific failure? where the exception is "The thread tried to read from or write to a virtual address for which it does not have the appropriate access" and from looking at the various threads running in this dump I wonder if it's just that you're stressing windows with a ton of native pinvokes that may not be intended to be called concurrently in the same process. Just an idea, it's been a long time since I've been on the Windows team :)

I've got two ideas to try to help you. Note I haven't done much more than review your code and builds and open up the dmp file above and looked at the AV in it.

  • First, I've asked @marklio over teams who is kind of a PInvoke whisperer to look at your code just in case (there's something fishy about the problem being release specific). No guarantee he'll have time to help and no promises but it might be something he has context or contacts on.

  • Secondly, I think given you are strongly asserting that this never repros locally that the most likely difference between your computer and the build machines is that they're Server Windows 10 SKUs and you use client, ergo various memory management things are different and the native windows things you're calling into might vary too. So, while it's definitely worth understanding what's going on here (classically there are always various devs and power users who insist on running server SKU as their development environment) you can probably make the flaky CI problem go away (but not whatever this underlying bug is!) by changing buildpool.server.amd64.vs2019.open to buildpool.windows.10.amd64.vs2019.open . If this unblocks you, please don't forget that you very likely have a real Windows Server bug and there are always customers quirky enough to use Winforms there.

Finally, I can (if you can get a corpnet jump box or use mine) provide you with a machine running our Server 2019 image, though I expect simply using the latest version from the Azure Gallery is likely to be able to fail the same way these build machines do, if that turns out to be the problem.

@hughbe
Copy link
Contributor

hughbe commented Jun 9, 2020

First, I've asked @marklio over teams who is kind of a PInvoke whisperer to look at your code just in case (there's something fishy about the problem being release specific). No guarantee he'll have time to help and no promises but it might be something he has context or contacts on.

I'm not sure if this is release specific - see crash in https://dev.azure.com/dnceng/public/_build/results?buildId=678166&view=logs&jobId=1f132584-ab08-5fbf-e5d0-5685de454342

System​.Windows​.Forms​.Tests​.WebBrowserTests​.WebBrowser​_Refresh​_Invoke​Web​Browser​Refresh​Option​With​Document​Text​_Success
System​.Windows​.Forms​.Tests​.Html​Document​Tests​.Html​Document​_Link​Color​_Get​Custom​Value​On​Body​_Returns​Expected
all other are are either starting up the thread or waiting to create their first handle, so most likely have not performed any interop yet

This is interesting because these tests are (relatively) new. There be a chance that bad interop definitions could be causing this. For example we did see that IHtmlElement4.FireEvent was defined incorrectly in a previous PR

@weltkante
Copy link
Contributor

weltkante commented Jun 9, 2020

Not only is it a possibility, we've already done it for you!

@RussKie might want to learn where to find those ;)

given you are strongly asserting that this never repros locally

I think thats a misunderstanding, its just failing very unreliably. Took me hours of local test runs to fail once with dumps enabled, but then it failed twice in a row (second dump here didn't get around to upload earlier)

there's something fishy about the problem being release specific

Definitely not release-only, I had it 4 times in debug build test runs so far, two of them with dumps (linked above).

from looking at the various threads running in this dump

Its easy to misread this, but really there isn't that much going on. There is a lot of congestion at thread startup/shutdown and there is no throttling so it looks like a lot of tests are running in parallel, but they really aren't, most are still starting up/winding down.

Theres certainly potential for optimizing by e.g. throttling the number of UI threads running at a time to the number of cores or something, but I'd rather first fix the memory corruption while we still can reproduce it.

In fact for the run in question I think this is a dump... doesn't seem to have your specific failure?

There is no specific failure, these are random test failures, most likely memory corruption.

In fact the crashing thread in the dump you linked seems to have is stack corrupted.


So far I've seen three dumps (two from me, linked above, and the one you linked). I guess I've been lucky that my first dump had so little active threads, the other two are much more work to look through. The three active tests (WebBrowser, HtmlDocument, ImageLists related) are all in common in the dumps so that doesn't help so far.

I agree with @hughbe that WebBrowser/Html code could have made a mistake during interop refactoring and are worth looking at the changesets again. Unfortunately WebBrowser engine is one of the largest infrastructures in WinForms (it includes ActiveX hosting) so might not be easy to spot by review alone.

I'll try to build reduced test suites which just include the set of 3 test classes identified above and see if they corrupt memory if run repeatedly, maybe that can narrow down what we have to look at.

Of course feel free to run your own investigations if you have the time to do so, just wanted to let you know I'm on it.

@MattGal
Copy link
Member

MattGal commented Jun 9, 2020

Not only is it a possibility, we've already done it for you!

@RussKie might want to learn where to find those ;)

Since these are builds you'll have to get Kusto access and use the AzDO API to figure out the "orchestration id" of your job to get this working. It's a bit tricky (it'd be free if your tests ran on helix test machines). @RussKie let me know if you want to send some instructions (and whether you have Kusto read access to engsrvprod).

@ghost ghost removed the 🚧 work in progress Work that is current in progress label Jul 2, 2020
@RussKie RussKie removed this from the 5.0 Preview8 milestone Jul 2, 2020
@RussKie RussKie reopened this Jul 14, 2020
@RussKie
Copy link
Member Author

RussKie commented Jul 14, 2020

@weltkante
Copy link
Contributor

I actually can't see PR #3526 addressing ListView ImageList ownership when switching on checked mode, so I'd guess its still the same corruption. Initially I had assumed it was just moved over to #3531 but considering that is 'Future' now I guess there has been some confusion.

@RussKie RussKie added this to the 5.0 GA milestone Jul 14, 2020
@RussKie
Copy link
Member Author

RussKie commented Jul 14, 2020

Yes, we had hopes that #3526 would help, but obviously we're wrong. We'll have to continue digging...

@hughbe
Copy link
Contributor

hughbe commented Jul 14, 2020

Did that PR help? It seems like there are like 5 different problems here - web browser, disposal, sharing of image lists, etc

@weltkante
Copy link
Contributor

weltkante commented Jul 14, 2020

To me it looks pretty clear. While there were a lot of secondary issues found while investigating there is only two sources of crashes identified:

Everything else has been split off into separate issues and has not been the source of crashes seen here.

Maybe it was not clear that turning on Checkboxes causes the crashes? It will trigger a double-free of the underlying native ImageList because there is a small chance that the same numeric handle value is reused again for an independent ImageList.

Fixing this requires handling ImageList ownership correctly when turning checkbox mode on, the native code is assuming it owns the ImageList and releases it, WinForms must not retain its copy of the handle. Since you don't control who else is using it you have to duplicate it before giving it to the ListView. Alternatively it might be possible to work around this by resetting the ImageList on the native control before turning checkbox mode on.

@RussKie
Copy link
Member Author

RussKie commented Jul 16, 2020

I don't believe WebBrowser has anything to do with these failures. I haven't observed it in any of the dumps I have.

Here's one of the latests AV crashes:

Not Flagged	>	42280	0	Worker Thread	System.Windows.Forms.Tests.ListViewTests.ListView_StateImageList_SetWithHandleWithNonNullOldValue_GetReturnsExpected	win32u.dll!_NtUserWaitMessage@0
Not Flagged		38412	0	Worker Thread	System.Windows.Forms.Tests.ScrollableControlTests.ScrollableControl_OnPaintBackground_InvokeWithHandle_Success	win32u.dll!_NtUserMsgWaitForMultipleObjectsEx@20
Not Flagged		40560	0	Worker Thread	System.Windows.Forms.Tests.ControlTests.Control_IsInputChar_InvokeWithHandle_ReturnsExpected	win32u.dll!_NtUserMsgWaitForMultipleObjectsEx@20
Not Flagged		42088	0	Worker Thread	System.Windows.Forms.Tests.TextBoxBaseTests.TextBoxBase_WndProc_InvokeMouseDownWithoutHandle_Success	win32u.dll!_NtUserMsgWaitForMultipleObjectsEx@20
Not Flagged		39268	0	Worker Thread	System.Windows.Forms.Tests.ToolStripItemTests.ToolStripItem_ImageAlign_SetWithOwnerWithHandle_GetReturnsExpected	win32u.dll!_NtUserMsgWaitForMultipleObjectsEx@20
Not Flagged		40208	0	Worker Thread	System.Windows.Forms.Tests.ButtonBaseTests.ButtonBase_OnMouseMove_InvokeWithHandle_CallsMouseMove	win32u.dll!_NtUserMsgWaitForMultipleObjectsEx@20
Not Flagged		42608	0	Worker Thread	System.Windows.Forms.Tests.TabPageTests.TabPageCollection_Text_SetGetItemsWithHandleDesignMode_Success	win32u.dll!_NtUserMsgWaitForMultipleObjectsEx@20
Not Flagged		48308	0	Worker Thread	System.Windows.Forms.Tests.ControlControlCollectionTests.ControlCollection_Add_ControlNewCollection_Success	win32u.dll!_NtUserMsgWaitForMultipleObjectsEx@20
Not Flagged		40188	0	Worker Thread	System.Windows.Forms.Tests.RichTextBoxTests.RichTextBox_Find_CharArrayIntInt_ReturnsExpected	win32u.dll!_NtUserMsgWaitForMultipleObjectsEx@20
Not Flagged		41032	0	Worker Thread	System.Windows.Forms.Tests.TreeViewTests.TreeView_OnHandleCreated_InvokeWithHandleWithProperties_CallsHandleCreated	win32u.dll!_NtUserMsgWaitForMultipleObjectsEx@20
Not Flagged		42672	0	Worker Thread	System.Windows.Forms.Tests.ToolStripTests.ToolStrip_OnControlAdded_Invoke_CallsControlAdded	win32u.dll!_NtUserMsgWaitForMultipleObjectsEx@20

This crash also results in a popup that hangs builds:
image

Maybe it was not clear that turning on Checkboxes causes the crashes? It will trigger a double-free of the underlying native ImageList because there is a small chance that the same numeric handle value is reused again for an independent ImageList.

Fixing this requires handling ImageList ownership correctly when turning checkbox mode on, the native code is assuming it owns the ImageList and releases it, WinForms must not retain its copy of the handle. Since you don't control who else is using it you have to duplicate it before giving it to the ListView. Alternatively it might be possible to work around this by resetting the ImageList on the native control before turning checkbox mode on.

As far as our research went this is the most likely cause, but so far we were unable to get to the bottom of the issue...
The code will require a refactor and a rewrite, and this requires time.

@weltkante
Copy link
Contributor

weltkante commented Jul 16, 2020

I don't believe WebBrowser has anything to do with these failures. I haven't observed it in any of the dumps I have.

They are reproducible though, even without any ImageList in play, see my other repro scenario in the repository. Its not always easy to separate dumps caused from memory corruption, in hindsight you may be right and the CI dumps are probably mostly ImageList handle collisions. The WebBrowser and ImageList tests always happened to run at roughly the same time and corruption from WebBrowser was much more frequent, at least for me running tests locally, so it reproduced more easily and was discovered first.

I don't think there is any point separating them into an issue of their own considering the WinForms side of the investigation is already over and the workaround in place, but if you want to track the response of the external investigation so you can reconsider removing the sequential attributes from tests I can create a separate issue if you want.

@ghost ghost added the 🚧 work in progress Work that is current in progress label Jul 17, 2020
@weltkante
Copy link
Contributor

weltkante commented Jul 17, 2020

As far as our research went this is the most likely cause, but so far we were unable to get to the bottom of the issue...
The code will require a refactor and a rewrite, and this requires time.

Made a PR which disables ImageList ownership sharing and instead manages ownership explicitly by creating unique ImageList handles when assigning to the native control. Your choice of whether you want to take it or live with the broken tests for now (until you can fix it), I've no strong opinion, I don't think it happens much in practice outside the unit tests

@hughbe
Copy link
Contributor

hughbe commented Jul 17, 2020

It would be really interesting to see if there’s some report of this snuck away in stack overflow or forums somewhere

@ghost ghost removed the 🚧 work in progress Work that is current in progress label Jul 22, 2020
@RussKie RussKie removed this from the 5.0 GA milestone Jul 27, 2020
@RussKie
Copy link
Member Author

RussKie commented Nov 3, 2020

For general reference, stumbled across this post that alleges an imagelist may be double destroyed if it is still bound to a control
https://social.msdn.microsoft.com/Forums/vstudio/en-US/e6b685d3-e407-4d5a-a7b7-faa0f7840375/cimagelistrelease-mfc-vs2005-winxp

@weltkante
Copy link
Contributor

I wouldn't put too much weight on that, he just saw the same thing I did. In particular its no indication of where the bug is, without repro to follow along you can't tell who is responsible for the off-by-one refcount. The incorrect release could have happened anywhere, it will just manifest in a bug when the last reference is released, so it will almost always blame the wrong location in the callstack, as the refcount could have been off-by-one for a long time.

RussKie added a commit to RussKie/winforms that referenced this issue Nov 27, 2020
Revert "Explicit ImageList ownership management. (dotnet#3601)"
This reverts commit 03db3fb.

Revert "Fix `ListView` no longer displays images (dotnet#4184)"
This reverts commit d0608e7.

We have observed an instability of tests under stress (and reasonably
high degree of concurrency) presumably caused by ImageList lifetime
handling (notably dotnet#3358).
The changes introduced in dotnet#3601 have helped with tests stability,
however resulted in a number of regressions, such as dotnet#4169 and dotnet#4275.

Restore the original implementation given it worked reasonably well for
the past so many years.
RussKie added a commit that referenced this issue Dec 2, 2020
Revert "Explicit ImageList ownership management. (#3601)"
This reverts commit 03db3fb.

Revert "Fix `ListView` no longer displays images (#4184)"
This reverts commit d0608e7.

We have observed an instability of tests under stress (and reasonably
high degree of concurrency) presumably caused by ImageList lifetime
handling (notably #3358).
The changes introduced in #3601 have helped with tests stability,
however resulted in a number of regressions, such as #4169 and #4275.

Restore the original implementation given it worked reasonably well for
the past so many years.
RussKie added a commit to RussKie/winforms that referenced this issue Dec 2, 2020
Revert "Explicit ImageList ownership management. (dotnet#3601)"
This reverts commit 03db3fb.

Revert "Fix `ListView` no longer displays images (dotnet#4184)"
This reverts commit d0608e7.

We have observed an instability of tests under stress (and reasonably
high degree of concurrency) presumably caused by ImageList lifetime
handling (notably dotnet#3358).
The changes introduced in dotnet#3601 have helped with tests stability,
however resulted in a number of regressions, such as dotnet#4169 and dotnet#4275.

Restore the original implementation given it worked reasonably well for
the past so many years.

(cherry picked from commit b0ee5da)
RussKie added a commit that referenced this issue Dec 9, 2020
Revert "Explicit ImageList ownership management. (#3601)"
This reverts commit 03db3fb.

Revert "Fix `ListView` no longer displays images (#4184)"
This reverts commit d0608e7.

We have observed an instability of tests under stress (and reasonably
high degree of concurrency) presumably caused by ImageList lifetime
handling (notably #3358).
The changes introduced in #3601 have helped with tests stability,
however resulted in a number of regressions, such as #4169 and #4275.

Restore the original implementation given it worked reasonably well for
the past so many years.

(cherry picked from commit b0ee5da)
@ghost ghost locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
test-bug Problem in test source code (most likely)
Projects
None yet
7 participants