Skip to content

TCE-1645 fix stack overflow issue - #278

Open
DMarinhoCodacy wants to merge 2 commits into
masterfrom
fix-exit-code-139
Open

DMarinhoCodacy wants to merge 2 commits into
masterfrom
fix-exit-code-139

Conversation

@DMarinhoCodacy

Copy link
Copy Markdown
Contributor

No description provided.

@codacy-production

codacy-production Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 2 minor

Results:
2 new issues

Category Results
CodeStyle 2 minor

View in Codacy

🟢 Metrics 4 complexity

Metric Results
Complexity 4

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

⚠️ Resolve issues before merging

The duplicate local declaration prevents the analyzer from compiling, so this must be fixed before merging.

Codacy also found:

  • 2 code-style findings in src/Analyzer/CodeAnalyzer.cs recommending braces around new control-flow bodies.

Test suggestions

  • Analyze a deeply nested C# file and verify it is skipped with the expected result instead of overflowing the stack.
  • Analyze a file at or below the depth threshold and verify normal diagnostics are produced.
  • Verify concurrent file analysis honors cancellation.
  • Verify the runtime configuration provides the intended enlarged thread stack.
  • Verify iterative syntax-tree depth calculation handles deep trees without recursion.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Analyze a deeply nested C# file and verify it is skipped with the expected result instead of overflowing the stack.
2. Analyze a file at or below the depth threshold and verify normal diagnostics are produced.
3. Verify concurrent file analysis honors cancellation.
4. Verify the runtime configuration provides the intended enlarged thread stack.
5. Verify iterative syntax-tree depth calculation handles deep trees without recursion.

TIP Add review instructions in .codacy/instructions/review.md, or an AGENTS.md, so the reviewer knows your conventions.
TIP How was this review? Give us feedback

Comment thread src/Analyzer/CodeAnalyzer.cs Resolved
var max = 0;
var stack = new Stack<(SyntaxNode Node, int Depth)>();
stack.Push((root, 1));
while (stack.Count > 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Cancellation can be delayed while large syntax trees are fully traversed, including after their depth already exceeds the limit. Consider checking the cancellation token during traversal and returning as soon as the limit is exceeded.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

var compilation = await solution.Projects.First().GetCompilationAsync();

var root = await compilation.SyntaxTrees.First().GetRootAsync(cancellationToken);
if (GetMaxDepth(root) > MaxSyntaxDepth)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Valid files deeper than 1,000 syntax nodes receive no diagnostics, even when the analyzers could process them with the enlarged stack. Consider a larger-stack fallback or a configurable limit instead of unconditionally skipping these files.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant