bUnit: 1.19.14 dotnet test crashes when running multiple tests

Describe the bug

After updating my nuget package reference to 1.19.14 dotnet test crashes with a stack overflow exception when running multiple tests.

This appears to happen after rendering when waiting for state. E.g.

        cut.WaitForState(() => cut.Instance.EntityPermission != null);

Results in this exception


Stack overflow.
   at System.Collections.Generic.Dictionary`2[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.AspNetCore.Components.RenderTree.ArrayRange`1[[Microsoft.AspNetCore.Components.RenderTree.RenderTreeFrame, Microsoft.AspNetCore.Components, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], Microsoft.AspNetCore.Components, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].GetBucket(UInt32)
   at System.Collections.Generic.Dictionary`2[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.AspNetCore.Components.RenderTree.ArrayRange`1[[Microsoft.AspNetCore.Components.RenderTree.RenderTreeFrame, Microsoft.AspNetCore.Components, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], Microsoft.AspNetCore.Components, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].FindValue(Int32)
   at System.Collections.Generic.Dictionary`2[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.AspNetCore.Components.RenderTree.ArrayRange`1[[Microsoft.AspNetCore.Components.RenderTree.RenderTreeFrame, Microsoft.AspNetCore.Components, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]], Microsoft.AspNetCore.Components, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ContainsKey(Int32)
   at Bunit.Rendering.RenderTreeFrameDictionary.Contains(Int32)
   at Bunit.Rendering.TestRenderer.GetOrLoadRenderTreeFrame(Bunit.Rendering.RenderTreeFrameDictionary, Int32)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
...
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.LoadRenderTreeFrames(Int32, Bunit.Rendering.RenderTreeFrameDictionary)
   at Bunit.Rendering.TestRenderer.UpdateDisplay(Microsoft.AspNetCore.Components.RenderTree.RenderBatch ByRef)
   at Bunit.Rendering.TestRenderer+<>c.<UpdateDisplayAsync>b__27_0(System.Object)
   at Xunit.Sdk.AsyncTestSyncContext.Send(System.Threading.SendOrPostCallback, System.Object)
   at Bunit.Rendering.TestRenderer.UpdateDisplayAsync(Microsoft.AspNetCore.Components.RenderTree.RenderBatch ByRef)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
   at Bunit.Rendering.TestRenderer.ProcessPendingRender()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(Int32, Microsoft.AspNetCore.Components.RenderFragment)
   at Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
   at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(Microsoft.AspNetCore.Components.EventCallbackWorkItem, System.Object)
   at AppPotion.Web.Ui.Shared.EntityEditor.EditorActionBarComponent+<ActionButtonClicked>d__23.MoveNext()
   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=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.TaskAwaiter+<>c.<OutputWaitEtwEvents>b__12_0(System.Action, System.Threading.Tasks.Task)
   at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback, System.Object, System.Threading.Tasks.Task ByRef)
   at System.Threading.Tasks.Task.RunContinuations(System.Object)
   at System.Threading.Tasks.Task`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.Threading.Tasks.VoidTaskResult)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].SetExistingTaskResult(System.Threading.Tasks.Task`1<System.Threading.Tasks.VoidTaskResult>, System.Threading.Tasks.VoidTaskResult)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult()
   at AppPotion.Web.Ui.Framework.EntityEditor.EntityActionDescriptor+<ExecuteAsync>d__43.MoveNext()
   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=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.TaskAwaiter+<>c.<OutputWaitEtwEvents>b__12_0(System.Action, System.Threading.Tasks.Task)
   at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback, System.Object, System.Threading.Tasks.Task ByRef)
   at System.Threading.Tasks.Task.RunContinuations(System.Object)
   at System.Threading.Tasks.Task`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.Threading.Tasks.VoidTaskResult)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].SetExistingTaskResult(System.Threading.Tasks.Task`1<System.Threading.Tasks.VoidTaskResult>, System.Threading.Tasks.VoidTaskResult)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult()
   at AppPotion.Web.Ui.Shared.EntityEditor.EntityEditorComponentBase`1+<AddNew>d__90[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   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=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.TaskAwaiter+<>c.<OutputWaitEtwEvents>b__12_0(System.Action, System.Threading.Tasks.Task)
   at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback, System.Object, System.Threading.Tasks.Task ByRef)
   at System.Threading.Tasks.Task.RunContinuations(System.Object)
   at System.Threading.Tasks.Task`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.Threading.Tasks.VoidTaskResult)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].SetExistingTaskResult(System.Threading.Tasks.Task`1<System.Threading.Tasks.VoidTaskResult>, System.Threading.Tasks.VoidTaskResult)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetResult()
   at AppPotion.Web.Ui.Shared.EntityEditor.EntityEditorComponentBase`1+<LoadEntityPermissionAsync>d__87[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   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=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.TaskAwaiter+<>c.<OutputWaitEtwEvents>b__12_0(System.Action, System.Threading.Tasks.Task)
   at System.Threading.Tasks.AwaitTaskContinuation.RunCallback(System.Threading.ContextCallback, System.Object, System.Threading.Tasks.Task ByRef)
   at System.Threading.Tasks.Task.RunContinuations(System.Object)
   at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.__Canon)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].SetExistingTaskResult(System.Threading.Tasks.Task`1<System.__Canon>, System.__Canon)
   at AppPotion.Web.Ui.Framework.AppState+<GetEntityPermissionAsync>d__116.MoveNext()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext(System.Threading.Thread)
   at System.Runtime.CompilerServices.TaskAwaiter+<>c.<OutputWaitEtwEvents>b__12_0(System.Action, System.Threading.Tasks.Task)
   at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation+<>c__DisplayClass6_0.<GetActionLogDelegate>b__0()
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(System.Threading.Tasks.TaskCompletionSource, System.Threading.SendOrPostCallback, System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
The program '[19708] dotnet.exe' has exited with code 3221225477 (0xc0000005) 'Access violation'.

Expected behavior: Tests should not crash dotnet tests and work as in previous versions of bunit.

Version info:

  • bUnit version: 1:19.14
  • .NET Runtime and Blazor version: .NET 7.0.5
  • OS type and version: Windows 10 Pro

Additional context:

I’m still trying to create a simple repro but reverting to 1.18.4 seems to resolve the issue.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 43 (23 by maintainers)

Most upvoted comments

Thanks, @David-Moreira, it is certainly giving us something to investigate.

The stack overflow that you and @groogiam are seeing indicates that the Blazor renderer’s render tree is in an inconsistent state. That should not be something that could happen and something that happens outside of bUnits control. It could be that it happens when we are disposing of the Blazor renderer and we are not guarding against accessing the render tree at that point.

cc. @linkdotnet.

In this case we are calling a Render() then asserting some internal state on the component. Depending on the scenario sometimes we may also have a WaitForState or WaitForElement.

Let’s keep the issue open for now, but focus on the overflow. Can you share the code that is in the “onclick” handler that is being invoked? It may give me a hint at what I should look for.

    private async Task Refresh()
    {
        if (!await ConfirmOverwriteUnsavedChanges())
        {
            return;
        }

        IsLoading = true;

        try
        {
            await LoadEntityInternal(); //makes odata http request

            await LoadEntityPermissionAsync(); //checks singleton service for cache entry otherwise makes http request for the permission.
        }
        finally
        {
            IsLoading = false;
        }

        await Ctx.MessageBus.PublishAsync(new EntityRefreshedMessage<TEntity>
        {
            Sender = this,
            Entity = Entity
        });

        await Ctx.MessageBus.PublishAsync(new EntityRefreshedMessage
        {
            Sender = this,
            EntityTypeName = EntityType.Name,
            Entity = Entity
        });

        Ctx.Notifier.SystemNotifySuccess("Refresh Complete");
    }

I would love an example of a test that works on xUnit and not in MSTest. bUnit is supposed to work with all major test frameworks.

I forgot a very important note, the SF Dictionary concurrent issue, did not seem to happen at all running test locally, only on pipeline everytime. In this case it’s in BitBucket. And well I was not seeing any reason why some concurrent access would be done, so I decided to try a diff testing framework and it worked… Not saying it’s the testing framework fault, there might be more at play here… but that was what immediately worked in this case.

Anyway I’ll see if I get around to it. Would have to try with GHActions. Anyway I’ll hit you up with an actual repro if I get around to it as that’s way more useful to you.

The original issue does not seem a problem anymore, at least for me as I’m even fine without the explicit Dispose. That’s something that was already in the project I am now working on and I don’t think it’s needed. Thanks.

I might be going off thread here…But are you guys using MSTest or have used with bUnit?

We use xUnit. But I do not think MSTest should be a problem. Haven’t heard anybody say so.

I’m thinking most of my problems might just straight up be to do with Thread Safety, I’m not sure how MSTest runs the tests that are inside a single [TestClass] (class with all the tests [TestMethod] inside) but it might just not be running them quite independently as one would have though.

The new tests that were failing because of some concurrent update (what the hell), I decided to refactor them into xUnit, put the [TestInitialize] into a ctor, and bam started passing.

I would love an example of a test that works on xUnit and not in MSTest. bUnit is supposed to work with all major test frameworks.

Anyway since removing the [TestCleanup] with the explicit TestContext.Dispose I haven’t seen the stack overflow error which was the original issue of this thread.

I explicitly fixed the dispose problem in the latest 1.20 preview release, so it should be safe to clean up and tell the renderer that you are done with the test.

I might be going off thread here…But are you guys using MSTest or have used with bUnit?

I’m thinking most of my problems might just straight up be to do with Thread Safety, I’m not sure how MSTest runs the tests that are inside a single [TestClass] (class with all the tests [TestMethod] inside) but it might just not be running them quite independently as one would have though.

The new tests that were failing because of some concurrent update (what the hell), I decided to refactor them into xUnit, put the [TestInitialize] into a ctor, and bam started passing.

Anyway since removing the [TestCleanup] with the explicit TestContext.Dispose I haven’t seen the stack overflow error which was the original issue of this thread.

@egil The change does not seem to help the original issue (non async click calls) on my local machine or CI. However it does seem stable on the updated code that utilizes async calls for actions. Setting TestContext.DefaultWaitTimeout to 30 seconds does seem to significantly slow down the test execution though. It seems like quite a few of my tests wait the entire timeout for some reason. Thanks.

Forgot to mention that I was on 1.18.4 and not on 1.19

We changed things in 1.19 that did forced some of the race conditions more into the light, so if you have more tests failing between the 1.18 and 1.19 that is not surprising.

First impressions:

  • Upon updating I had tests fail that never failed before, I had to put WaitFor in a few, gives the sense that either bUnit stopped waiting for initial renders, or somehow it’s become faster that WaitFor is almost essential.

bUnit has never waited for components that perform async operations. If you have anything that is not completely synchronous (returning Task.CompletedTask counts), then you need to use one of the WaitFor methods. E.g. if you have a Task.Delay or similar.

  • Have two that failed that already had WaitFor, basically now they behave slightly different, gotta take some time to investigate those… I disabled them for now just for the sake of testing.
  • I also started getting these that I didn’t get before as soon as I activated 4 workers, on Syncfusion Charts components… image - EDIT: I got these also when switching back to 1 worker… all in all seems to be very unstable for me. I’ll prioritize staying in 1.18, but i’ll try testing the latest stable 1.19 when i have time just to see if I get the same problems as I’m getting with the preview.

I don’t know if any of these help. And they’re kinda unrelated to the original overflow problem…

I will try to keep posting feedback but as you know sometimes time is limited to be allocating to test troubleshooting.

My experience with our own tests is that with the latest preview they are completely stable, but I did have to increase the default wait for timeout when running on CI or slow hardware. My AMD 5950x has no problem ever. 5 year old laptop and GitHub actions, especially GitHub actions on windows and osx, has.

Forgot to mention that I was on 1.18.4 and not on 1.19 First impressions:

  • Upon updating I had tests fail that never failed before, I had to put WaitFor in a few, gives the sense that either bUnit stopped waiting for initial renders, or somehow it’s become faster that WaitFor is almost essential.
  • Have two that failed that already had WaitFor, basically now they behave slightly different, gotta take some time to investigate those… I disabled them for now just for the sake of testing.
  • I also started getting these that I didn’t get before as soon as I activated 4 workers, on Syncfusion Charts components… image - EDIT: I got these also when switching back to 1 worker… all in all seems to be very unstable for me. I’ll prioritize staying in 1.18, but i’ll try testing the latest stable 1.19 when i have time just to see if I get the same problems as I’m getting with the preview.

I don’t know if any of these help. And they’re kinda unrelated to the original overflow problem…

I will try to keep posting feedback but as you know sometimes time is limited to be allocating to test troubleshooting.

@egil Appreciated the fast response. Will let you know the results as soon as possible.

Hello,

I have also the same problem on a new project I’m working on with MSTest + bUnit.

I joined this project, mid way so there were already alot of tests in place and it’s hard to track what’s causing it, but by enabling parallelize I get the same behavior as OP transiently, more frequently, so sometimes it would fail, sometimes not… It does seem something to do with shared state. Just can’t tell from where, codebase or actual Blazor engine.

One thing of note is that like OP, we are also using the WaitFor helpers, if that helps.

Also recently it was suddently happening very frequently even on sequential(non parallel) run, by removing the TestContext.Dispose from the TestCleanUp it fixed it, not sure it is to do with having an async dispose on it. But anyway I’m trusting the framework to still cleanup / Dispose properly of TestContext.


These kind of problems are always hard to diagnose, troubleshoot, if I figure out a reproducible I’ll post it here.