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

Dispose of ThreadRental at conclusion of UITheory test #47

Merged
merged 1 commit into from
May 16, 2020
Merged

Conversation

AArnott
Copy link
Owner

@AArnott AArnott commented May 16, 2020

Fixes #44 hang at end of test run.

@AArnott AArnott added this to the v1.0 milestone May 16, 2020
@AArnott AArnott self-assigned this May 16, 2020
@AArnott
Copy link
Owner Author

AArnott commented May 16, 2020

@weltkante Would you review?

Copy link

@weltkante weltkante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks sensible. I've downloaded the artifact and can confirm both the repro and winforms no longer hang.

@weltkante
Copy link

weltkante commented May 16, 2020

I've started seeing following exception. Not sure if its related to this change. I doubt its related to the other PR (I'm using this PR's artifact). Also I'm not entirely sure if its a new issue or existed before and just wasn't surfacing due to the hang.

The stack trace is a bit weird, with a failed debug assert mixed into it, I'm still trying to figure out how to diagnose this, doesn't happen when debugging tests from inside VS [edit] turns out I was debugging the wrong tests

Unhandled exception. System.InvalidOperationException: Invoke oder BeginInvoke kann für ein Steuerelement erst aufgerufen werden, wenn das Fensterhandle erstellt wurde.
   at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous) in D:\projects\winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 6896
   at System.Windows.Forms.Control.BeginInvoke(Delegate method, Object[] args) in D:\projects\winforms\src\System.Windows.Forms\src\System\Windows\Forms\Control.cs:line 4707
   at System.Windows.Forms.WindowsFormsSynchronizationContext.Post(SendOrPostCallback d, Object state) in D:\projects\winforms\src\System.Windows.Forms\src\System\Windows\Forms\WindowsFormsSynchronizationContext.cs:line 90
   at Xunit.Sdk.Utilities.SyncContextAwaiter.OnCompleted(Action continuation)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AwaitUnsafeOnCompleted[TAwaiter](TAwaiter& awaiter, IAsyncStateMachineBox box)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__139_1(Object state)
   at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Process terminated. Assertion Failed
Marshaling control should have created its handle in its ctor.
   at System.Windows.Forms.WindowsFormsSynchronizationContext..ctor() in D:\projects\winforms\src\System.Windows.Forms\src\System\Windows\Forms\WindowsFormsSynchronizationContext.cs:line 35
   at System.Windows.Forms.WindowsFormsSynchronizationContext.InstallIfNeeded() in D:\projects\winforms\src\System.Windows.Forms\src\System\Windows\Forms\WindowsFormsSynchronizationContext.cs:line 143
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context) in D:\projects\winforms\src\System.Windows.Forms\src\System\Windows\Forms\Application.ThreadContext.cs:line 1119
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(msoloop reason, ApplicationContext context) in D:\projects\winforms\src\System.Windows.Forms\src\System\Windows\Forms\Application.ThreadContext.cs:line 992
   at System.Windows.Forms.Application.DoEvents() in D:\projects\winforms\src\System.Windows.Forms\src\System\Windows\Forms\Application.cs:line 811
   at Xunit.Sdk.WinFormsSynchronizationContextAdapter.PumpTill(SynchronizationContext synchronizationContext, Task task)
   at Xunit.Sdk.ThreadRental.<>c__DisplayClass11_0.<CreateAsync>b__0()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

@weltkante
Copy link

Yeah can confirm this is not the fault of this PR, I rolled back to 1.0.31-beta and skipped the hanging test assembly and I was already getting the same crash. Just never seen it before because the hanging test assembly runs before the crashing one.

@AArnott
Copy link
Owner Author

AArnott commented May 16, 2020

Thanks for testing. I trust you'll file another bug if you find the crash you saw is due to xunit.stafact.

@AArnott AArnott merged commit c72b73e into master May 16, 2020
@AArnott AArnott deleted the fix44 branch May 16, 2020 23:19
@weltkante
Copy link

if you find the crash you saw is due to xunit.stafact

Looks like this needs to be adressed in the WinForms unit tests, they are disposing the SC early. Probably shouldn't be WinFormsFacts if they setup/terminate the infrastructure manually.

@AArnott
Copy link
Owner Author

AArnott commented May 17, 2020

@weltkante I'm not sure whether you're blaming the WinFormsFactAttribute behavior or the unit tests in the WinForms repo. Can you clarify?

@weltkante
Copy link

weltkante commented May 17, 2020

Not blaming stafact, continuing discussion on dotnet/winforms#3297

AArnott added a commit that referenced this pull request Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hanging UITheoryTestCase
2 participants