dotnet / dotnet/roslyn

SyntaxTrivia.RequiredUnderlyingNode fails assertion when building SDK repo

Open
#80,869 1 comment 0 reactions 1 assignee Claimed by @RikkiGibson View on GitHub
Area-Compilers
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

This occurred when opening the sdk repo in VS Code, with a `dotnet.server.path` pointing to locally built debug version of the language server. I am unsure whether this would occur also if using a debug compiler on the command line. I didn't want to spend further time investigating for now, but, wanted to record the fact that I encountered it.

I was working in an SDK branch based off of https://github.com/dotnet/sdk/commit/da83df940bb8270e04103f9d5a43ce6d50e6b31d. The roslyn bits were probably the same as I used in #80840.

Stack trace

```
2025-10-23 10:17:08.773 [error] [stderr] Process terminated. Assertion failed.
node is object
at Microsoft.CodeAnalysis.SyntaxTrivia.get_RequiredUnderlyingNode() in F:\src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxTrivia.cs:line 64
at Microsoft.CodeAnalysis.SyntaxToken.<>c.b__86_0(SyntaxTrivia t) in F:\src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxToken.cs:line 480
at Microsoft.CodeAnalysis.GreenNode.CreateList[TFrom](IReadOnlyList`1 list, Func`2 select) in F:\src\roslyn\src\Compilers\Core\Portable\Syntax\GreenNode.cs:line 941
at Microsoft.CodeAnalysis.GreenNode.CreateList[TFrom](IEnumerable`1 enumerable, Func`2 select) in F:\src\roslyn\src\Compilers\Core\Portable\Syntax\GreenNode.cs:line 908
at Microsoft.CodeAnalysis.SyntaxToken.WithLeadingTrivia(IEnumerable`1 trivia) in F:\src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxToken.cs:line 479
at Microsoft.CodeAnalysis.SyntaxNodeExtensions.WithLeadingTrivia[TSyntax](TSyntax node, IEnumerable`1 trivia) in F:\src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxNodeExtensions.cs:line 364
at Microsoft.CodeAnalysis.SyntaxNodeExtensions.WithLeadingTrivia[TSyntax](TSyntax node, SyntaxTrivia[] trivia) in F:\src\roslyn\src\Compilers\Core\Portable\Syntax\SyntaxNodeExtensions.cs:line 385
at Microsoft.Windows.CsWin32.Generator.WhitespaceRewriter.VisitUsingDirective(UsingDirectiveSyntax node)
at Microsoft.CodeAnalysis.CSharp.Syntax.UsingDirectiveSyntax.Accept[TResult](CSharpSyntaxVisitor`1 visitor) in F:\src\roslyn\src\Compilers\CSharp\Portable\Generated\CSharpSyntaxGenerator\CSharpSyntaxGenerator.SourceGenerator\Syntax.xml.Syntax.Generated.cs:line 9438
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.Visit(SyntaxNode node) in F:\src\roslyn\src\Compilers\CSharp\Portable\Syntax\CSharpSyntaxRewriter.cs:line 41
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitListElement[TNode](TNode node) in F:\src\roslyn\src\Compilers\CSharp\Portable\Syntax\CSharpSyntaxRewriter.cs:line 168
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitList[TNode](SyntaxList`1 list) in F:\src\roslyn\src\Compilers\CSharp\Portable\Syntax\CSharpSyntaxRewriter.cs:line 145
at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitCompilationUnit(CompilationUnitSyntax node) in F:\src\roslyn\src\Compilers\CSharp\Portable\Generated\CSharpSyntaxGenerator\CSharpSyntaxGenerator.SourceGenerator\Syntax.xml.Main.Generated.cs:line 1957
at Microsoft.CodeAnalysis.CSharp.Syntax.CompilationUnitSyntax.Accept[TResult](CSharpSyntaxVisitor`1 visitor) in F:\src\roslyn\src\Compilers\CSharp\Portable\Generated\CSharpSyntaxGenerator\CSharpSyntaxGenerator.SourceGenerator\Syntax.xml.Syntax.Generated.cs:line 9290
at Microsoft.Windows.CsWin32.Generator.<>c__DisplayClass110_0.b__1(KeyValuePair`2 kv)
at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()
at System.Linq.Parallel.QueryTask.BaseWork(Object unused)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.