stryker-mutator / stryker-net

Mutation testing for .NET core and .NET framework!
https://stryker-mutator.io
Apache License 2.0
1.75k stars 176 forks source link

System.IndexOutOfRangeException: Index was outside the bounds of the array. #2921

Closed mu88 closed 1 month ago

mu88 commented 2 months ago

Describe the bug

When running Stryker, it fails after some time with the following exception, but only for certain solutions:

System.IndexOutOfRangeException: Index was outside the bounds of the array.

Logs

10:23:37  + ./tools/dotnet-stryker --reporter Html --reporter cleartext --reporter json --mutation-level Complete --output StrykerOutput_MyApp --config-file stryker-config.json
10:23:37  
10:23:37     _____ _              _               _   _ ______ _______  
10:23:37    / ____| |            | |             | \ | |  ____|__   __| 
10:23:37   | (___ | |_ _ __ _   _| | _____ _ __  |  \| | |__     | |    
10:23:37    \___ \| __| '__| | | | |/ / _ \ '__| | . ` |  __|    | |    
10:23:37    ____) | |_| |  | |_| |   <  __/ |    | |\  | |____   | |    
10:23:37   |_____/ \__|_|   \__, |_|\_\___|_| (_)|_| \_|______|  |_|    
10:23:37                     __/ |                                      
10:23:37                    |___/                                       
10:23:37  
10:23:37  
10:23:37  Version: 4.0.4
10:23:37  
10:23:37  [08:23:37 INF] Analysis starting.
10:23:37  [08:23:37 INF] Identifying projects to mutate in /home/jenkins/agent/workspace/s_Utility_MutationTesting_master/my-app/Stryker.sln. This can take a while.
10:23:50  [08:23:48 INF] Found 3 source projects
10:23:50  [08:23:48 INF] Found 1 test projects
10:23:50  [08:23:48 INF] Found project /home/jenkins/agent/workspace/s_Utility_MutationTesting_master/my-app/tests/MyCompany.MyApp.Tests.Common/MyCompany.MyApp.Tests.Common.csproj to mutate.
10:23:50  [08:23:48 INF] Found project /home/jenkins/agent/workspace/s_Utility_MutationTesting_master/my-app/src/MyCompany.MyApp.Features/MyCompany.MyApp.Features.csproj to mutate.
10:23:50  [08:23:48 INF] Found project /home/jenkins/agent/workspace/s_Utility_MutationTesting_master/my-app/src/MyCompany.MyApp.Core/MyCompany.MyApp.Core.csproj to mutate.
10:23:50  [08:23:49 INF] Analysis complete.
10:23:50  [08:23:49 INF] Building solution Stryker.sln
10:24:08  [08:24:08 INF] Number of tests found: 971 for project /home/jenkins/agent/workspace/s_Utility_MutationTesting_master/my-app/tests/MyCompany.MyApp.Tests.Common/MyCompany.MyApp.Tests.Common.csproj. Initial test run started.
10:24:15  [08:24:15 INF] Number of tests found: 971 for project /home/jenkins/agent/workspace/s_Utility_MutationTesting_master/my-app/src/MyCompany.MyApp.Features/MyCompany.MyApp.Features.csproj. Initial test run started.
10:24:22  [08:24:22 INF] Number of tests found: 971 for project /home/jenkins/agent/workspace/s_Utility_MutationTesting_master/my-app/src/MyCompany.MyApp.Core/MyCompany.MyApp.Core.csproj. Initial test run started.
10:24:38  [08:24:35 ERR] An error occurred during the mutation test run 
10:24:38  System.AggregateException: One or more errors occurred. (Index was outside the bounds of the array.)
10:24:38   ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
10:24:38     at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value, Int32& location)
10:24:38     at System.Collections.Generic.HashSet`1.Add(T item)
10:24:38     at Stryker.Core.Mutants.MutantPlacer.RegisterEngine(IInstrumentCode engine, Boolean requireRecursive)
10:24:38     at Stryker.Core.Mutants.CsharpNodeOrchestrators.BaseFunctionOrchestrator`1..ctor()
10:24:38     at Stryker.Core.Mutants.CsharpNodeOrchestrators.AnonymousFunctionExpressionOrchestrator..ctor()
10:24:38     at Stryker.Core.Mutants.CsharpMutantOrchestrator.BuildOrchestratorList()
10:24:38     at Stryker.Core.Mutants.CsharpMutantOrchestrator..ctor(MutantPlacer placer, IEnumerable`1 mutators, StrykerOptions options)
10:24:38     at Stryker.Core.MutationTest.CsharpMutationProcess.Mutate(MutationTestInput input)
10:24:38     at Stryker.Core.MutationTest.MutationTestProcess.Mutate()
10:24:38     at Stryker.Core.Initialisation.ProjectMutator.MutateProject(StrykerOptions options, MutationTestInput input, IReporter reporters)
10:24:38     at Stryker.Core.Initialisation.ProjectOrchestrator.<>c__DisplayClass7_0.<MutateProjects>b__0(MutationTestInput mutationTestInput)
10:24:38     at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
10:24:38  --- End of stack trace from previous location ---
10:24:38     at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
10:24:38     at System.Threading.Tasks.TaskReplicator.Replica.Execute()
10:24:38     --- End of inner exception stack trace ---
10:24:38     at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
10:24:38     at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
10:24:38  --- End of stack trace from previous location ---
10:24:38     at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
10:24:38     at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
10:24:38     at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
10:24:38     at Stryker.Core.Initialisation.ProjectOrchestrator.MutateProjects(StrykerOptions options, IReporter reporters, ITestRunner runner)
10:24:38     at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs, ILoggerFactory loggerFactory, IProjectOrchestrator projectOrchestrator)
10:24:38  [08:24:35 INF] Time Elapsed 00:00:58.2697433
10:24:38  Unhandled exception. System.AggregateException: One or more errors occurred. (Index was outside the bounds of the array.)
10:24:38   ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
10:24:38     at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value, Int32& location)
10:24:38     at System.Collections.Generic.HashSet`1.Add(T item)
10:24:38     at Stryker.Core.Mutants.MutantPlacer.RegisterEngine(IInstrumentCode engine, Boolean requireRecursive)
10:24:38     at Stryker.Core.Mutants.CsharpNodeOrchestrators.BaseFunctionOrchestrator`1..ctor()
10:24:38     at Stryker.Core.Mutants.CsharpNodeOrchestrators.AnonymousFunctionExpressionOrchestrator..ctor()
10:24:38     at Stryker.Core.Mutants.CsharpMutantOrchestrator.BuildOrchestratorList()
10:24:38     at Stryker.Core.Mutants.CsharpMutantOrchestrator..ctor(MutantPlacer placer, IEnumerable`1 mutators, StrykerOptions options)
10:24:38     at Stryker.Core.MutationTest.CsharpMutationProcess.Mutate(MutationTestInput input)
10:24:38     at Stryker.Core.MutationTest.MutationTestProcess.Mutate()
10:24:38     at Stryker.Core.Initialisation.ProjectMutator.MutateProject(StrykerOptions options, MutationTestInput input, IReporter reporters)
10:24:38     at Stryker.Core.Initialisation.ProjectOrchestrator.<>c__DisplayClass7_0.<MutateProjects>b__0(MutationTestInput mutationTestInput)
10:24:38     at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
10:24:38  --- End of stack trace from previous location ---
10:24:38     at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
10:24:38     at System.Threading.Tasks.TaskReplicator.Replica.Execute()
10:24:38     --- End of inner exception stack trace ---
10:24:38     at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
10:24:38     at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
10:24:38  --- End of stack trace from previous location ---
10:24:38     at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
10:24:38     at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
10:24:38     at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
10:24:38     at Stryker.Core.Initialisation.ProjectOrchestrator.MutateProjects(StrykerOptions options, IReporter reporters, ITestRunner runner)
10:24:38     at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs, ILoggerFactory loggerFactory, IProjectOrchestrator projectOrchestrator)
10:24:38     at Stryker.CLI.StrykerCli.RunStryker(IStrykerInputs inputs) in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 102
10:24:38     at Stryker.CLI.StrykerCli.<>c__DisplayClass11_0.<Run>b__0() in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 74
10:24:38     at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.<OnExecute>b__0(CancellationToken _)
10:24:38     at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
10:24:38     at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
10:24:38     at Stryker.CLI.StrykerCli.Run(String[] args) in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 80
10:24:38     at Stryker.CLI.Program.Main(String[] args) in /_/src/Stryker.CLI/Stryker.CLI/Program.cs:line 14
10:24:38  Aborted (core dumped)

Expected behavior

No error should be thrown as it used to work nicely on previous versions.

Desktop (please complete the following information):

Additional context

Running it locally on my dev laptop, I cannot reproduce the issue. I temporarily moved back to 4.0.3 on Jenkins which seems to mitigate the issue.

dupdob commented 1 month ago

this problem should have been fixed by recent releases (4.0.5 or 4.0.6) I close this issue under this assumption. Please reopen it if the problem is still present