The AL Language server crashes with a stack overflow
まだ誰も着手していません。
評価
調査の方向性
Start with the attached minimal project and the stack trace in the issue; reproduce using AL 18.1.43.24897 with the two listed assemblies in the probing path, then compare with AL 17.10 and without System.Drawing.Common.dll. The trace points to CecilAssemblyResolver and recursive ExportedType.Resolve calls. Done means the compiler handles the forwarding cycle without crashing, at most reporting the type as unresolved.
索引モデルが issue の本文から書いたものです。
説明
Bug report
The AL Language server crashes with a stack overflow when it opens our base application project, and after 5 crashes VS Code shows "The AL server crashed 5 times in the last 3 minutes. The server will not be restarted." The command-line compiler (alc.exe) crashes the same way, exit code 0xC00000FD (3221225725).
The bug started in AL Language extension 18.x. It happens with 18.1.2842859 (compiler 18.1.43.24897). Version 17.10.2902953 compiles the same project with 0 errors.
Environment
- Project: Business Central 19 base application on the BC20 platform,
"platform": "20.0.0.0","runtime": "9.2","target": "OnPrem" - Local BC20 container created with BcContainerHelper
- Windows 11
al.assemblyProbingPaths:
[
"C:\\ProgramData\\BcContainerHelper\\Extensions\\<container>\\.netPackages",
"C:\\WINDOWS\\Microsoft.NET\\assembly"
]
Minimal repro (attached zip)
An empty project (platform 20.0.0.0, runtime 9.2, target OnPrem) with only this dotnet.al crashes alc.exe 18.1.43.24897 with a stack overflow (exit code 0xC00000FD). No variables are needed:
dotnet
{
assembly("System.Windows.Forms")
{
Version = '4.0.0.0';
Culture = 'neutral';
PublicKeyToken = 'b77a5c561934e089';
type("System.Windows.Forms.PrintDialog"; "PrintDialog")
{
}
}
}
al.assemblyProbingPaths points to a folder with only two DLLs:
System.Windows.Forms.dll4.0.0.0 from .NET Framework 4.8 (GAC_MSIL)System.Drawing.Common.dll6.0.0.0, file version 6.0.21.52210, from NuGet System.Drawing.Common 6.0.0lib/net461(BC20 ships this file in its Service folder)
Results:
- AL 18.1.43.24897: stack overflow
- AL 17.10.2902953: compiles, exit code 0
- AL 18.1 without System.Drawing.Common.dll in the folder: compiles, exit code 0
Probable cause
While loading the members of PrintDialog, System.Drawing resolves to the compiler's own .NET 10 runtime facade (Microsoft.NETCore.App\10.0.x\System.Drawing.dll, version 4.0.0.0). That facade forwards the drawing types to System.Drawing.Common. System.Drawing.Common resolves through the probing path to the 6.0.0.0 net461 build, which forwards the same types back to System.Drawing 4.0.0.0. That again resolves to the .NET 10 facade, so ExportedType.Resolve recurses until the stack overflows.
The compiler should not crash on a type-forwarding cycle. For OnPrem targets it should probably also prefer .NET Framework assemblies from the probing paths over its own runtime's facades.
Stack trace (trimmed)
Stack overflow.
at Mono.Cecil.AssemblyNameReference.Parse(System.String)
at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.AssemblyLocatorBase.GetAssemblyName(System.String)
at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.AssemblyLocatorBase.GetPathToAssembly(System.String)
at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilAssemblyResolver.Resolve(Mono.Cecil.AssemblyNameReference)
at Mono.Cecil.MetadataResolver.Resolve(Mono.Cecil.TypeReference)
at Mono.Cecil.ModuleDefinition.Resolve(Mono.Cecil.TypeReference)
at Mono.Cecil.ExportedType.Resolve()
at Mono.Cecil.MetadataResolver.GetType(Mono.Cecil.ModuleDefinition, Mono.Cecil.TypeReference)
... (the last four frames repeat until the stack overflows) ...
at Mono.Cecil.TypeReference.Resolve()
at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeInfoProvider.GetTypeDefinition(Mono.Cecil.TypeReference)
at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeInfoProvider.GetReturnTypeInfo(Mono.Cecil.TypeReference)
at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeInfoProvider.BuildPropertyInfo(...)
at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeInfoProvider.BuildPropertyInfoList(...)
at Microsoft.Dynamics.Nav.CodeAnalysis.DotNet.Cecil.CecilDotNetTypeLoader.LoadType(...)
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceDotNetTypeDeclarationSymbol.LazyGetType()
...
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceAttributeSymbol.CheckAttribute()
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceVariableSymbol.ForceCompleteAttributes(...)
at Microsoft.Dynamics.Nav.CodeAnalysis.Symbols.SourceCodeunitTypeSymbol.ForceComplete(...)
Expected behavior
The compiler should not crash on a type-forwarding cycle; at most it should report the type as unresolved.
Platform
Windows
5. Versions:
-
AL Language extension active in VS Code: 18.1.2842859, the version that crashes
-
Visual Studio Code: Version: 1.143.1 (user setup)
-
Business Central application: 20.18.60911.0 (FI)
-
Business Central platform: 20.0.60870.0
-
Operating System:
- [ X] Windows
- Linux
- MacOS
- 主要言語
- PowerShell
- スター
- 889
- フォーク
- 285
- 平均マージ
- 4時間 7分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/AL のほかの issue
-
accepted al-tools bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
suggestion
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
似ている issue
-
confirmed generated by fuzzer llvm:codegen miscompilation
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
llvm/llvm-project#237380 ·
メンテナーはふだん 1 日以内に返信
-
area:observer area:trace-tape found-by:code-review kind:docs-drift
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
InauguralSystems/EigenScript#2212 ·
メンテナーはふだん 1 日以内に返信
-
bug medium priority openmp tokenizer wrong result
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
import: a segment starting with a digit is refused, but the error says digits are allowed対応中かも @sebastianbreguel が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
HigherOrderCO/Bend#1961 ·
-
bug pdd
難易度 2/5 1時間未満 初心者へのやさしさ 60/100
objectionary/eo#9675 ·
メンテナーはふだん 1 日以内に返信