SymbolicExecutionRunner threw an exception of type SymbolicExecutionException

SonarQube 8.3.0.34182
SonarLint 4.22.0.18519
SonarAnalyzer.CSharp 8.8.0.18411
Visual Studio 2017 Professional

Our project is bound to SonarQube and has SonarAnalyzer.CSharp installed and the SonarLint plugin. When I build I’m seeing the following warning:

‘’'Severity Code Description Project File Line Suppression State
Warning AD0001 Analyzer ‘SonarAnalyzer.Rules.SymbolicExecution.SymbolicExecutionRunner’ threw an exception of type ‘SonarAnalyzer.SymbolicExecution.SymbolicExecutionException’ with message
'Error processing method: xxxxxxxxxxxxxxxx ##
Method file: C:\Perforce\xxx\xxxx\xxx\xxxxxxxxxxxx\xxxxxxxx\xxxxxxxxxxxxxx.cs ##
Method line: 1283,8 ##
Inner exception: System.NotSupportedException: Neither one of BoolConstraint, ObjectConstraint,StringConstraint or DisposableConstraint. ##
at SonarAnalyzer.SymbolicExecution.SymbolicValue.TrySetObjectConstraint(ObjectConstraint constraint, SymbolicValueConstraints oldConstraints, ProgramState programState) ##
at SonarAnalyzer.SymbolicExecution.SymbolicValue.TrySetConstraint(SymbolicValueConstraint constraint, ProgramState programState) ##
at System.Linq.Enumerable.d__172.MoveNext() ## at System.Linq.Enumerable.<SelectManyIterator>d__172.MoveNext() ##
at SonarAnalyzer.SymbolicExecution.CSharpExplodedGraph.VisitBinaryBranch(BinaryBranchBlock binaryBranchBlock, ExplodedGraphNode node, SyntaxNode instruction) ##
at SonarAnalyzer.SymbolicExecution.AbstractExplodedGraph.Walk() ##
at SonarAnalyzer.Rules.SymbolicExecution.SymbolicExecutionRunner.Analyze(CSharpExplodedGraph explodedGraph, SyntaxNodeAnalysisContext context) ##
at SonarAnalyzer.SymbolicExecution.FlowAnalysisExtensions.Analyze(CSharpSyntaxNode declarationBody, ISymbol symbol, Action`2 analyze, SyntaxNodeAnalysisContext context) ## ‘. xxxxxxx.xxxx C:\Perforce\xxx\xxxx\xxx\xxxxxxxxxxxx\CSC 1 Active
‘’’

I’ve tried to replicate in a sample project but was unable to. Is this a known issue?

Thanks.

1 Like

Hi @nblackburn

Thanks for letting us know. To answer your question, no, this issue is not know or nor expected. We will look into that.

If possible, it would be great to share the method content since this will help us a lot to reproduce and fix the problem.

I’ve added an issue on sonar-dotnet and you can follow the progress here: https://github.com/SonarSource/sonar-dotnet/issues/3403

Best,
Costin

1 Like

Hi @costin.zaharia

Thanks for your reply, the method is below:

private bool SetValueInternal(Number? value, bool reformat, bool userModified)
{
	bool result = false;
	Number? lastValue = this.Value;

	if (userModified && lastValue != value)
	{
		OnUserModifiedValue();
	}

	if (reformat)
	{
		this.Value = value;
	}
	else
	{
		this.hasValue = (value != null);

		if (this.hasValue)
		{
			this.value = (Number)value;
		}

		if (this.Value != lastValue)
		{
			OnPropertyChanged("Value");
		}
	}

	if (userModified && lastValue != value)
	{
		OnUserChangedValueApplied(this.Value);
	}

	if (lastValue != this.Value)
	{
		result = true;
	}

	return result;
}

Number is our own custom Struct.

If there’s anything else I can provide please let me know. I was unable to reproduce this in a sample project but I could have another attempt. It happens for every build of our main project though.

Thanks.

Hi Neil,

Thank you for your reply.

Our symbolic execution engine is handling the analysis at the method level so having the method code and the stack trace is already very good. We will give you a sign though if something else is needed.

Thanks,
Costin

Hi @nblackburn,

We’re trying to fix this issue this week but we can’t reproduce it with the provided code. Inspecting the provided call stack shows that the path should not be called during analysis of your SetValueInternal function.

Are you sure that you’re looking at the correct file, correct class (in case there are multiple or nested classes in the file) and correct overload?

Provided call stack suggests that some regular (not a nullable?) argument or variable is checked for null/not null value (directly or indirectly).

Later update: Can be related to nullable as well, somehow.

Thanks
Pavel