Skip to content

Concurrency problem in PlatformServiceProvider.GetTestContext #3953

Description

@stan-sz

Describe the bug

Concurrency problem in Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.PlatformServiceProvider.GetTestContext

Steps To Reproduce

MSTest 3.6.1 + MSTest.SDK (using MSTest Runner)

Expected behavior

No exception

Actual behavior

System.AggregateException: One or more errors occurred. (Source array was not long enough. Check the source index, length, and the array's lower bounds. (Parameter 'sourceArray'))
---> System.ArgumentException: Source array was not long enough. Check the source index, length, and the array's lower bounds. (Parameter 'sourceArray')
   at System.Array.CopyImpl(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Array.Copy(Array sourceArray, Array destinationArray, Int32 length)
   at System.Collections.Generic.List`1.set_Capacity(Int32 value)
   at System.Collections.Generic.List`1.AddWithResize(T item)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.TestRunCancellationToken.Register(Action callback) in /_/src/Adapter/MSTest.TestAdapter/Execution/TestRunCancellationToken.cs:line 61
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.PlatformServiceProvider.GetTestContext(ITestMethod testMethod, StringWriter writer, IDictionary`2 properties) in /_/src/Adapter/MSTest.TestAdapter/PlatformServiceProvider.cs:line 161
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner.RunSingleTest(TestMethod testMethod, IDictionary`2 testContextProperties) in /_/src/Adapter/MSTest.TestAdapter/Execution/UnitTestRunner.cs:line 141
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTestsWithTestRunner(IEnumerable`1 tests, ITestExecutionRecorder testExecutionRecorder, String source, IDictionary`2 sourceLevelParameters, UnitTestRunner testRunner) in /_/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs:line 438
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.<>c__DisplayClass21_1.<ExecuteTestsInSource>b__7() in /_/src/Adapter/MSTest.TestAdapter/Execution/TestExecutionManager.cs:line 363
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.WaitAllCore(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)

Metadata

Metadata

Assignees

Labels

state/in-prA PR is open for this issue.

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions