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 test: Button_Default_WithText_LineDrawing crashed with System.AccessViolationException #3918

Closed
Tracked by #8607
RussKie opened this issue Sep 16, 2020 · 4 comments
Assignees
Labels
test-bug Problem in test source code (most likely)
Milestone

Comments

@RussKie
Copy link
Member

RussKie commented Sep 16, 2020

  • .NET Core Version:

release/5.0-RC2

Problem description:

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

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.FillRect(HDC, RECT ByRef, HBRUSH)
--------------------------------
   at System.Windows.Forms.DeviceContextExtensions.FillRectangle(HDC, System.Drawing.Rectangle, HBRUSH)
   at System.Windows.Forms.DeviceContextExtensions.FillRectangle(System.Windows.Forms.DeviceContextHdcScope, System.Drawing.Rectangle, HBRUSH)
   at System.Windows.Forms.Control.PaintBackColor(System.Windows.Forms.PaintEventArgs, System.Drawing.Rectangle, System.Drawing.Color)
   at System.Windows.Forms.Control.PaintBackground(System.Windows.Forms.PaintEventArgs, System.Drawing.Rectangle, System.Drawing.Color, System.Drawing.Point)
   at System.Windows.Forms.Control.PaintBackground(System.Windows.Forms.PaintEventArgs, System.Drawing.Rectangle)
   at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.PaintButtonBackground(System.Windows.Forms.PaintEventArgs, System.Drawing.Rectangle, System.Drawing.Brush)
   at System.Windows.Forms.ButtonInternal.ButtonStandardAdapter.PaintWorker(System.Windows.Forms.PaintEventArgs, Boolean, System.Windows.Forms.CheckState)
   at System.Windows.Forms.ButtonInternal.ButtonStandardAdapter.PaintUp(System.Windows.Forms.PaintEventArgs, System.Windows.Forms.CheckState)
   at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.Paint(System.Windows.Forms.PaintEventArgs)
   at System.Windows.Forms.ButtonBase.PaintControl(System.Windows.Forms.PaintEventArgs)
   at System.Windows.Forms.ButtonBase.OnPaint(System.Windows.Forms.PaintEventArgs)
   at System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs, Int16)
   at System.Windows.Forms.Control.OnPrint(System.Windows.Forms.PaintEventArgs)
   at System.Windows.Forms.Control.WmPrintClient(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ButtonBase.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Button.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.CallWindowProcW(IntPtr, IntPtr, WM, IntPtr, IntPtr)
   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.ButtonBase.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Button.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 System.Windows.Forms.ControlExtensions.PrintToMetafile(System.Windows.Forms.Control, System.Windows.Forms.Metafiles.EmfScope, PRF)
   at System.Windows.Forms.Tests.ButtonRenderingTests.Button_Default_WithText_LineDrawing()
   at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean, Boolean)
   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 System.Windows.Forms.Application.DoEvents()
   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 added the test-bug Problem in test source code (most likely) label Sep 16, 2020
@RussKie RussKie added this to the 6.0 Preview1 milestone Sep 16, 2020
@JeremyKuhne
Copy link
Member

I'd be somewhat surprised if this test itself is flaky.

@RussKie
Copy link
Member Author

RussKie commented Sep 24, 2020

Another similar failure (https://dev.azure.com/dnceng/public/_build/results?buildId=828511&view=results):

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.FillRect(HDC, RECT ByRef, HBRUSH)
--------------------------------
   at System.Windows.Forms.DeviceContextExtensions.FillRectangle(HDC, System.Drawing.Rectangle, HBRUSH)
   at System.Windows.Forms.DeviceContextExtensions.FillRectangle(System.Windows.Forms.DeviceContextHdcScope, System.Drawing.Rectangle, HBRUSH)
   at System.Windows.Forms.Control.PaintBackColor(System.Windows.Forms.PaintEventArgs, System.Drawing.Rectangle, System.Drawing.Color)
   at System.Windows.Forms.Control.PaintBackground(System.Windows.Forms.PaintEventArgs, System.Drawing.Rectangle, System.Drawing.Color, System.Drawing.Point)
   at System.Windows.Forms.Control.PaintBackground(System.Windows.Forms.PaintEventArgs, System.Drawing.Rectangle)
   at System.Windows.Forms.Control.OnPaintBackground(System.Windows.Forms.PaintEventArgs)
   at System.Windows.Forms.ScrollableControl.OnPaintBackground(System.Windows.Forms.PaintEventArgs)
   at System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs, Int16)
   at System.Windows.Forms.Control.OnPrint(System.Windows.Forms.PaintEventArgs)
   at System.Windows.Forms.Control.WmPrintClient(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ContainerControl.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Form.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.CallWindowProcW(IntPtr, IntPtr, WM, IntPtr, IntPtr)
   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.Form.DefWndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.ContainerControl.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.Form.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 System.Windows.Forms.ControlExtensions.PrintToMetafile(System.Windows.Forms.Control, System.Windows.Forms.Metafiles.EmfScope, PRF)
   at System.Windows.Forms.Tests.ButtonRenderingTests.CaptureButtonOnForm()

There's a memdump available

The failing stack trace is as follows:

>	ntdll.dll!RtlpExecuteHandlerForException() Line 132	Unknown	Symbols loaded.
 	ntdll.dll!RtlDispatchException(_EXCEPTION_RECORD * ExceptionRecord=0x000000ec068fb4b0, _CONTEXT * ContextRecord=0x000000ec068fafc0) Line 628	C	Symbols loaded.
 	ntdll.dll!KiUserExceptionDispatch() Line 749	Unknown	Symbols loaded.
 	gdi32full.dll!MDC::pvNewRecord(unsigned long nSize=12) Line 227	C++	Symbols loaded.
 	gdi32full.dll!MF_SetD(void * hdc, unsigned long d1=2147483648, unsigned long mrType=37) Line 150	C++	Symbols loaded.
 	gdi32full.dll!MF_SelectAnyObject(void * hdc=0xffffffffd2210a7d, void * h=0x0000000000900010, unsigned long mrType=37) Line 1297	C++	Symbols loaded.
 	gdi32full.dll!SelectObjectImpl(HDC__ * hdc=0xffffffffd2210a7d, void * h=0x0000000000900010) Line 2609	C	Symbols loaded.
 	gdi32full.dll!PolyPatBlt(HDC__ * hdc=0xffffffffd2210a7d, unsigned long rop=15728673, _POLYPATBLT * pPoly=0x000000ec068fb8e0, unsigned long Count=1, unsigned long Mode=0) Line 674	C	Symbols loaded.
 	user32.dll!FillRect(HDC__ * hdc, const tagRECT * prc, HBRUSH__ * hBrush) Line 85	C++	Symbols loaded.

@JeremyKuhne
Copy link
Member

Bizarre. I'll look closer today to see what I can figure out.

@JeremyKuhne JeremyKuhne self-assigned this Sep 24, 2020
@JeremyKuhne JeremyKuhne added the 🚧 work in progress Work that is current in progress label Sep 24, 2020
@RussKie
Copy link
Member Author

RussKie commented Sep 28, 2020

Another failure (Release/x64) but with a different error:

    System.Windows.Forms.Tests.ButtonRenderingTests.Button_Default_WithText_LineDrawing [FAIL]
      System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
      Stack Trace:
           at System.Collections.Generic.List`1.set_Item(Int32 index, T value)
        /_/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs(154,0): at System.Windows.Forms.Metafiles.EmfScope.<>c__DisplayClass11_0.<EnumerateWithState>g__stateTracker|0(EmfRecord& record)
        /_/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs(225,0): at System.Windows.Forms.Metafiles.EmfScope.CallBack(HDC hdc, HGDIOBJ* lpht, ENHMETARECORD* lpmr, Int32 nHandles, IntPtr data)
           at Interop.Gdi32.EnumEnhMetaFile(HDC hdc, HENHMETAFILE hmf, Enhmfenumproc proc, IntPtr param, RECT* lpRect)
        /_/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs(72,0): at System.Windows.Forms.Metafiles.EmfScope.Enumerate(ProcessRecordDelegate enumerator)
        /_/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/EmfScope.cs(93,0): at System.Windows.Forms.Metafiles.EmfScope.EnumerateWithState(ProcessRecordWithStateDelegate enumerator, DeviceContextState state)
        /_/src/System.Windows.Forms.Primitives/tests/TestUtilities/Metafiles/Validators/EmfValidator.cs(28,0): at System.Windows.Forms.Metafiles.EmfValidator.Validate(EmfScope emf, DeviceContextState state, IEmfValidator[] validationSteps)
        /_/src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ButtonRenderingTests.cs(84,0): at System.Windows.Forms.Tests.ButtonRenderingTests.Button_Default_WithText_LineDrawing()

@RussKie RussKie modified the milestones: 6.0 Preview1, 6.0 Preview2 Jan 27, 2021
@RussKie RussKie modified the milestones: 6.0 Preview2, 6.0 Preview3 Feb 23, 2021
@RussKie RussKie modified the milestones: 6.0 Preview3, 6.0 Mar 24, 2021
@dreddy-work dreddy-work modified the milestones: 6.0, 6.0 rtm Sep 14, 2021
@RussKie RussKie modified the milestones: 6.0 rtm, 7.0 Nov 3, 2021
@RussKie RussKie removed the 🚧 work in progress Work that is current in progress label Nov 3, 2021
@dreddy-work dreddy-work modified the milestones: .NET 7.0, .NET 8.0 Aug 15, 2022
@ghost ghost added 🚧 work in progress Work that is current in progress and removed 🚧 work in progress Work that is current in progress labels Mar 14, 2023
@JeremyKuhne JeremyKuhne modified the milestones: .NET 8.0, .NET 9.0 Aug 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2024
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
Development

Successfully merging a pull request may close this issue.

3 participants