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

System.AggregateException: One or more errors occurred. (Internal error due to compile error.) #3096

Open
renatosc opened this issue Nov 6, 2024 · 3 comments
Labels
🐛 Bug Something isn't working

Comments

@renatosc
Copy link

renatosc commented Nov 6, 2024

Describe the bug
Stryker throws exception: "System.AggregateException: One or more errors occurred. (Internal error due to compile error.)"

Logs
log.txt

[16:49:58 WRN] Stryker.NET encountered a compile error in S:\repos\MyProject\src\MyProject.Logic\Search.cs (at 354:21) with message: Use of unassigned local variable 'helper' (Source code: helper)
[16:49:58 INF] Safe Mode! Stryker will flag mutations in Condition as compile error.
[16:50:00 ERR] An error occurred during the mutation test run
System.AggregateException: One or more errors occurred. (Internal error due to compile error.)
 ---> Stryker.Core.Exceptions.CompilationException: Internal error due to compile error.
   at Stryker.Core.Compiling.CSharpRollbackProcess.Start(CSharpCompilation compiler, ImmutableArray1 diagnostics, Boolean lastAttempt, Boolean devMode) in /_/src/Stryker.Core/Stryker.Core/Compiling/CSharpRollbackProcess.cs:line 75
....

The function that is failing is like this (redacted, summarized):

public void Condition(){	
	...

	foreach (var items in values) {
		var condition = JsonConvert.DeserializeObject<ConditionData>(item);
		if (condition == null || !helpers.TryGetValue(condition.Id, out var helper)) 
		{
			continue;
		}
		source = helper.Apply(source, condition.Id)
	}
	return source;
}

My guess the mutation is removing out var helper and thus the line source = helper.Apply() fails. But why this just doesn't safe fail (like, compilation failed, mutation killed), I don't know.

As a work-around, I tried excluding the file from being mutated, but it didn't work, still got the error. Also tried to exclude the helpers.TryGetValue method from being mutated but also same error.

Expected behavior
Stryker does not throw exception

Desktop (please complete the following information):

  • OS: Windows
  • Type of project: Core
  • Framework Version: Core 8
  • Stryker Version: 4.3.0

Additional context

  • If I keep re-running, it ends up running without exception, but most of the time it throws exception.
  • Running stryker with "--dev-mode" does not make any difference
@renatosc renatosc added the 🐛 Bug Something isn't working label Nov 6, 2024
@dupdob
Copy link
Member

dupdob commented Nov 6, 2024

hello
Thanks for reporting this and digging into this. This obviously should not happen.
As a reminder, Stryker's strategy is to inject as much mutations as possible and then to remove the ones that cause compilation errors. Sometimes, Stryker cannot establish a clear relationship between the error and the mutation causing it. Then it triggers what is called 'safe mode' and actually removes every mutations from the method to make sure it compiles.

I am surprised because there have never been any issue with same mode in years. So I suspect this is a red herring.
Since there is a 2 seconds gap between the two last log lines (which is a lot, in CPU time), the actual cause may be some other problem.

Anyway, I have a few things that may help you and help us helping you.

  1. have you tried using Stryker comments to disable mutation for this line or method ? Stryker comments is the surest way to ensure no mutation is actually injected into source code.
...
// Stryker disable once all
if (condition == null || !helpers.TryGetValue(condition.Id, out var helper)) 
...

This will disable mutating this line altogether. If you still have a compilation error, the problem comes from something else, and we will need the whole log file to help identify the cause. Even better, if you can share the problematic project, or a smaller project reproducing the issue this would be great.
BTW, you can privately send us the log/project via our Slack if you want to.

Finally, I think the mutation causing problem is the mutation of logical 'or' to logical 'and'

if (condition == null && !helpers.TryGetValue(condition.Id, out var helper)) 
{
	continue;
}
// here there is no guarantee that helper is initialized, as TryGetValue will not be called if condition!=null
source = helper.Apply(source, condition.Id)

Hope this helps

@dupdob dupdob added the ! Need more info ! More information is required to start or continue working on this issue label Nov 6, 2024
@renatosc
Copy link
Author

renatosc commented Nov 6, 2024

Thank you for your quick reply. Using Stryker Comments ( // Stryker disable once all) indeed made Stryker ignore that line and now it runs successfully.

And I think you are right, probably the mutation that was making helper to be undefined was the logical condition instead of the method call (which explains why ignoring the method call was not making any impact). Although I tried to ignore the filename also and could not get it to work....

My solution has multiple projects and multiple tests projects, to make it easier to isolate the problem I started calling stryker passing just 1 project and 1 test project and the error never happened. So, I have feeling that I may not be able to replicate the problem by isolating the project alone, but I will try.

I also ran stryker with trace verbosity and log to file (before adding the Stryker comment), I will review it and update here.

@dupdob dupdob removed the ! Need more info ! More information is required to start or continue working on this issue label Nov 6, 2024
@dupdob
Copy link
Member

dupdob commented Nov 6, 2024

thanks for the update. I am happy for you that the comment fixed the problem.
The bad news is that this makes no sense to me. Maybe the safe mode failed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants