microsoft / microsoft/win32metadata

win32metadata stuck in loop when scanning header with C++ templates

Open
#1,686 5 comments 0 reactions 1 assignee Claimed by @tannergooding View on GitHub
Dominant language
C++
Stars
1.5k
Forks
149
Avg merge
5d 16h
Merged PRs (30d)
4

Description

When building metadata for headers that include template specialization, ClangSharp appears to get stuck in a loop and eventually crash.

### Steps to reproduce
1. `git clone https://github.com/riverar/repro-29005f7a7a48rs`
2. `cd repro-29005f7a7a48rs`
3. `dotnet build`
4. Observe errors

### Output

```
Processing 'C:\Sources\repro-29005f7a7a48rs\repro.cpp'
Stack overflow.
at ClangSharp.Interop.CXType.get_IsTypeAlias()
at ClangSharp.TemplateSpecializationType.get_IsTypeAlias()
at ClangSharp.PInvokeGenerator.IsType[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](ClangSharp.Cursor, ClangSharp.Type, System.__Canon ByRef)
at ClangSharp.PInvokeGenerator.IsType[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](ClangSharp.Cursor, ClangSharp.Type, System.__Canon ByRef)
[...]
at ClangSharp.PInvokeGenerator.IsType[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](ClangSharp.Cursor, ClangSharp.Type, System.__Canon ByRef)
at ClangSharp.PInvokeGenerator.IsType[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](ClangSharp.Cursor, ClangSharp.Type, System.__Canon ByRef)
at ClangSharp.PInvokeGenerator.IsType[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](ClangSharp.Cursor, ClangSharp.Type, System.__Canon ByRef)
at ClangSharp.PInvokeGenerator.IsType[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](ClangSharp.Cursor, ClangSharp.Type, System.__Canon ByRef)
at ClangSharp.PInvokeGenerator.GetRecordDecl(ClangSharp.CXXBaseSpecifier)
at ClangSharp.PInvokeGenerator.g__IsEmptyRecord|100_7(ClangSharp.RecordDecl, <>c__DisplayClass100_0 ByRef)
at ClangSharp.PInvokeGenerator.g__IsExcludedByName|100_3(ClangSharp.Cursor, UInt32 ByRef, <>c__DisplayClass100_0 ByRef)
at ClangSharp.PInvokeGenerator.IsExcluded(ClangSharp.Cursor, Boolean ByRef)
at ClangSharp.PInvokeGenerator.IsExcluded(ClangSharp.Cursor)
at ClangSharp.PInvokeGenerator.VisitDecl(ClangSharp.Decl)
at ClangSharp.PInvokeGenerator.Visit(ClangSharp.Cursor)
at ClangSharp.PInvokeGenerator.Visit(System.Collections.Generic.IEnumerable`1)
at ClangSharp.PInvokeGenerator.VisitTranslationUnitDecl(ClangSharp.TranslationUnitDecl)
at ClangSharp.PInvokeGenerator.VisitDecl(ClangSharp.Decl)
at ClangSharp.PInvokeGenerator.Visit(ClangSharp.Cursor)
at ClangSharp.PInvokeGenerator.GenerateBindings(ClangSharp.TranslationUnit, System.String, System.String[], ClangSharp.Interop.CXTranslationUnit_Flags)
at ClangSharp.Program.Run(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Handler+<>c__DisplayClass1_0`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].b__0(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Invocation.AnonymousCommandHandler+<>c__DisplayClass2_0.<.ctor>g__Handle|0(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Invocation.AnonymousCommandHandler+d__3.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Invocation.AnonymousCommandHandler+d__3, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__3 ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[System.CommandLine.Invocation.AnonymousCommandHandler+d__3, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__3 ByRef)
at System.CommandLine.Invocation.AnonymousCommandHandler.InvokeAsync(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_0+<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_0.b__0(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_2.b__3(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass18_0+<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass18_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass18_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass18_0.b__0(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_2.b__3(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass13_0+<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass13_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass13_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass13_0.b__0(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_2.b__3(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass20_0+<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass20_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass20_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass20_0.b__0(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_2.b__3(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c+<b__19_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c+<b__19_0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__19_0>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c+<b__19_0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__19_0>d ByRef)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c.b__19_0(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_2.b__3(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass17_0+<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass17_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass17_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass17_0.b__0(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_2.b__3(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c+<b__6_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c+<b__6_0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__6_0>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c+<b__6_0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__6_0>d ByRef)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c.b__6_0(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_2.b__3(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c.b__7_0(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_2.b__3(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass9_0+<b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass9_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass9_0+<b__0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__0>d ByRef)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c__DisplayClass9_0.b__0(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_2.b__3(System.CommandLine.Invocation.InvocationContext)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c+<b__1_0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c+<b__1_0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__1_0>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[System.CommandLine.Builder.CommandLineBuilderExtensions+<>c+<b__1_0>d, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<b__1_0>d ByRef)
at System.CommandLine.Builder.CommandLineBuilderExtensions+<>c.b__1_0(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_1.b__2(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_1.b__2(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_1.b__2(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_1.b__2(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_1.b__2(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_1.b__2(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_1.b__2(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_1.b__2(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+<>c__DisplayClass4_1.b__2(System.CommandLine.Invocation.InvocationContext, System.Func`2)
at System.CommandLine.Invocation.InvocationPipeline+d__2.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Invocation.InvocationPipeline+d__2, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__2 ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[System.CommandLine.Invocation.InvocationPipeline+d__2, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__2 ByRef)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(System.CommandLine.IConsole)
at System.CommandLine.Parsing.ParseResultExtensions+d__0.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Parsing.ParseResultExtensions+d__0, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__0 ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[System.CommandLine.Parsing.ParseResultExtensions+d__0, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__0 ByRef)
at System.CommandLine.Parsing.ParseResultExtensions.InvokeAsync(System.CommandLine.Parsing.ParseResult, System.CommandLine.IConsole)
at System.CommandLine.Parsing.ParserExtensions+d__3.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.CommandLine.Parsing.ParserExtensions+d__3, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__3 ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[System.CommandLine.Parsing.ParserExtensions+d__3, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__3 ByRef)
at System.CommandLine.Parsing.ParserExtensions.InvokeAsync(System.CommandLine.Parsing.Parser, System.String[], System.CommandLine.IConsole)
at ClangSharp.Program+d__40.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[ClangSharp.Program+d__40, ClangSharpPInvokeGenerator, Version=16.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]](d__40 ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[ClangSharp.Program+d__40, ClangSharpPInvokeGenerator, Version=16.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]](d__40 ByRef)
at ClangSharp.Program.Main(System.String[])
at ClangSharp.Program.(System.String[])

```

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.