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

error AD0001: SonarAnalyzer.Rules.CSharp.SymbolicExecutionRunner showed up with SonarAnalyzer.Csharp 9.20.0.85982 #8787

Closed
jaz2038 opened this issue Feb 20, 2024 · 2 comments · Fixed by #8790
Assignees
Labels
Area: C# C# rules related issues. Type: Bug Exceptions and blocking issues during analysis.
Milestone

Comments

@jaz2038
Copy link

jaz2038 commented Feb 20, 2024

Description

Upgraded SonarAnalyzer.CSharp from 9.19.0.84025 to 9.20.0.85982 and started hitting this error with multiple builds:

CSC : error AD0001: Analyzer 'SonarAnalyzer.Rules.CSharp.SymbolicExecutionRunner' threw an exception of type 'SonarAnalyzer.SymbolicExecution.SymbolicExecutionException' with message 'Error processing method: XXX 
 Method file: YYY 
 Method line: 120,4 
 Inner exception: System.NullReferenceException: Object reference not set to an instance of an object. 
    at SonarAnalyzer.SymbolicExecution.Roslyn.BinaryOperatorKindExtensions.NumberConstraintFromRelationalOperator(BinaryOperatorKind kind, NumberConstraint existingNumber, NumberConstraint comparedNumber) 
    at SonarAnalyzer.SymbolicExecution.Roslyn.OperationProcessors.IsPattern.LearnBranchingConstraint(ProgramState state, IPatternOperationWrapper pattern, Boolean falseBranch, Boolean hasObjectConstraint, NumberConstraint numberConstraint) 
    at SonarAnalyzer.SymbolicExecution.Roslyn.OperationProcessors.IsPattern.LearnBranchingConstraint(ProgramState state, IIsPatternOperationWrapper operation, Boolean falseBranch) 
    at SonarAnalyzer.SymbolicExecution.Roslyn.OperationProcessors.BranchingProcessor`1.Process(SymbolicContext context, T operation) 
    at SonarAnalyzer.SymbolicExecution.Roslyn.OperationProcessors.MultiProcessor`1.Process(SymbolicContext context) 
    at SonarAnalyzer.SymbolicExecution.Roslyn.OperationDispatcher.Process(SymbolicContext context) 
    at SonarAnalyzer.SymbolicExecution.Roslyn.RoslynSymbolicExecution.ProcessOperation(ExplodedNode node)+MoveNext() 
    at SonarAnalyzer.SymbolicExecution.Roslyn.RoslynSymbolicExecution.Execute() 
    at SonarAnalyzer.Rules.SymbolicExecutionRunnerBase.AnalyzeRoslyn(SonarAnalysisContext analysisContext, SonarSyntaxNodeReportingContext nodeContext, ISymbol symbol)'. 

Repro steps

This error occurred in several areas of code, looks like typically happens with a switch:
private static double GetNormalizedNumMonthsForPastDate(double numMonths) { var normalizedNumMonths = numMonths switch { < 0 => Constants.MinMonthsValue, >= Constants.MaxMonthsValue => Constants.MinMonthsValue, _ => 12 - numMonths }; normalizedNumMonths += 1; return normalizedNumMonths; }

Known workarounds

Related information

  • C# 12.0
  • Jetbrains Rider 2023.3.3
  • .net 8.0.2
  • MacOS
@jaz2038
Copy link
Author

jaz2038 commented Feb 21, 2024

@zsolt-kolbay-sonarsource looks like potential regression introduced in this PR: #8686

@zsolt-kolbay-sonarsource
Copy link
Contributor

Thank you for reporting the issue. We will treat it with high priority.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Type: Bug Exceptions and blocking issues during analysis.
Projects
None yet
3 participants