Stack overflow when trying to process ICoreWebView2 within Microsoft.Web.WebView2.Core.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.5k
- Forks
- 124
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 9
Description
Actual behavior
Stack overflow when trying to process Microsoft.Web.WebView2.Core.winmd.
Expected behavior
No stack overflow.
Repro steps
-
Create the project:
dotnet new console -n webview2-cswin32 cd webview2-cswin32 dotnet package add Microsoft.Web.WebView2 dotnet package add Microsoft.Windows.CsWin32 -
Update
webview2-cswin32.csprojto add@(ProjectionMetadataWinmd)forMicrosoft.Web.WebView2.Core.winmd:<ItemGroup> <!-- update this, adding %(GeneratePathProperty) --> <PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3967.48" GeneratePathProperty="true" /> </ItemGroup> <ItemGroup> <ProjectionMetadataWinmd Include="$(PkgMicrosoft_Web_WebView2)\lib\Microsoft.Web.WebView2.Core.winmd" /> </ItemGroup> -
NativeMethods.txtcontent:ICoreWebView2 -
NativeMethods.jsoncontent:{ "$schema": "https://aka.ms/CsWin32.schema.json", "comInterop": { "useComSourceGenerators": true }, "emitSingleFile": false }
Please see this project: webview2-cswin32.zip
It may build the first time:
> dotnet build
…
…\webview2-cswin32\NativeMethods.txt(1,1): warning PInvoke001: Method, type or constant "ICoreWebView2" not found
Subsequent builds will fail:
> donet build
…
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error Stack overflow.
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at System.Runtime.EH.DispatchEx(System.Runtime.StackFrameIterator ByRef, ExInfo ByRef)
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.Windows.CsWin32.Generator.<IsManagedType>g__Helper|352_0(System.Reflection.Metadata.TypeDefinitionHandle, <>c__DisplayClass352_0 ByRef)
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.Windows.CsWin32.Generator.IsManagedType(System.Reflection.Metadata.TypeDefinitionHandle)
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.Windows.CsWin32.Generator.IsManagedType(Microsoft.Windows.CsWin32.TypeHandleInfo)
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.Windows.CsWin32.HandleTypeHandleInfo.ToTypeSyntax(Microsoft.Windows.CsWin32.TypeSyntaxSettings, GeneratingElement, System.Nullable`1<Microsoft.Windows.CsWin32.QualifiedCustomAttributeHandleCollection>, System.Reflection.ParameterAttributes)
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.Windows.CsWin32.Generator.<IsManagedType>g__Helper|352_0(System.Reflection.Metadata.TypeDefinitionHandle, <>c__DisplayClass352_0 ByRef)
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.Windows.CsWin32.Generator.IsManagedType(System.Reflection.Metadata.TypeDefinitionHandle)
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.Windows.CsWin32.Generator.IsManagedType(Microsoft.Windows.CsWin32.TypeHandleInfo)
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.Windows.CsWin32.HandleTypeHandleInfo.ToTypeSyntax(Microsoft.Windows.CsWin32.TypeSyntaxSettings, GeneratingElement, System.Nullable`1<Microsoft.Windows.CsWin32.QualifiedCustomAttributeHandleCollection>, System.Reflection.ParameterAttributes)
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.Windows.CsWin32.Generator.<IsManagedType>g__Helper|352_0(System.Reflection.Metadata.TypeDefinitionHandle, <>c__DisplayClass352_0 ByRef)
…
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.CodeAnalysis.CommandLine.BuildClient.Run(System.Collections.Generic.IEnumerable`1<System.String>, Microsoft.CodeAnalysis.CommandLine.RequestLanguage, Microsoft.CodeAnalysis.CommandLine.CompileFunc, Microsoft.CodeAnalysis.CommandLine.CompileOnServerFunc, Microsoft.CodeAnalysis.CommandLine.ICompilerServerLogger)
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.MainCore(System.String[])
C:\Program Files\dotnet\sdk\10.0.203\Roslyn\Microsoft.CSharp.Core.targets(89,5): error at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(System.String[])
Build failed with 764 error(s) and 1 warning(s) in 6.0s
Context
- CsWin32 version: 0.3.275
- Target Framework: net10.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by building the supplied webview2-cswin32 project with the shown .csproj, NativeMethods.txt, and NativeMethods.json files to reproduce the overflow. Trace the repeated calls through Microsoft.Windows.CsWin32.Generator.IsManagedType and HandleTypeHandleInfo.ToTypeSyntax; done means the ICoreWebView2 input no longer causes a stack overflow during subsequent builds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100