Stack overflow when a quotation contains a list literal of about a thousand elements
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- fsharp
- 領域
- compilers
調査の方向性
The crash is in QuotationTranslator.fs, where ConvExprCore and ConvExpr recurse once per list element; the repro in the issue (a quotation with a 1500-element list literal, run with dotnet fsi) reproduces it. Compare with how StackGuard is applied in the type checker and PostInferenceChecks, which the issue notes this file lacks. Done means the repro script prints done and the existing quotation tests still pass.
索引モデルが issue の本文から書いたものです。
説明
QuotationTranslator recurses once per element of a list literal and has no stack guard, so a quotation that contains a long list literal crashes the compiler with a stack overflow.
Repro steps
- Generate a script with a list literal of 1500 elements inside a quotation:
// gen.fsx
let elements = String.concat "; " [ for i in 1..1500 -> string i ]
System.IO.File.WriteAllText("repro.fsx", "let q = <@ [ " + elements + " ] @>\nprintfn \"done\"")
- Run
dotnet fsi gen.fsx, thendotnet fsi repro.fsx.
Expected behavior
The script prints done. The same list literal outside a quotation compiles (tried 5000 elements), and so does [| ... |] inside a quotation (tried 10000).
Actual behavior
The process crashes:
Stack overflow.
at FSharp.Compiler.TypedTreeOps.TupleCompilation.|Let|_|(Expr)
at FSharp.Compiler.TypedTreeOps.TupleCompilation.|CompiledForEachExpr|_|(TcGlobals, Expr)
at FSharp.Compiler.TypedTreeOps.TupleCompilation.|CompiledInt32RangeForEachExpr|_|(TcGlobals, Expr)
at FSharp.Compiler.TypedTreeOps.TupleCompilation.DetectAndOptimizeForEachExpression(TcGlobals, OptimizeForExpressionOptions, Expr)
Repeated 1165 times:
--------------------------------
at FSharp.Compiler.QuotationTranslator.ConvExprCore(QuotationGenerationScope, QuotationTranslationEnv, Expr)
at FSharp.Compiler.QuotationTranslator.ConvExpr(QuotationGenerationScope, QuotationTranslationEnv, Expr)
at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[...]
at Microsoft.FSharp.Primitives.Basics.List.map[...]
--------------------------------
at FSharp.Compiler.QuotationTranslator.ConvExprCore(QuotationGenerationScope, QuotationTranslationEnv, Expr)
at FSharp.Compiler.QuotationTranslator.ConvExpr(QuotationGenerationScope, QuotationTranslationEnv, Expr)
at FSharp.Compiler.QuotationTranslator.ConvExprPublic(QuotationGenerationScope, Boolean, Expr)
at FSharp.Compiler.PostTypeCheckSemanticChecks.doData@1416(...)
The threshold in dotnet fsi is between 800 and 1000 elements on SDK 10.0.402 and between 1000 and 1250 on SDK 11.0.100-rc.2. QuotationTranslator.fs does not use StackGuard, unlike the type checker and PostInferenceChecks.
It was found while compiling tests/fsharp/typeProviders/helloWorld/provider.fsx in the FSharp.Compiler.ComponentTests host: a quotation there with a list of a few dozen elements overflowed with a Debug build of the compiler on a thread-pool thread.
Known workarounds
Use an array literal.
Related information
- Windows 11, x64
- .NET Core (SDK 10.0.402 and 11.0.100-rc.2.26504.105,
dotnet fsi)
- 主要言語
- F#
- スター
- 4.3k
- フォーク
- 881
- 平均マージ
- 3日 23時間
- マージ済み PR(30日)
- 110
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
dotnet/fsharp のほかの issue
-
Needs-Triage
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 3 日以内に返信
-
Semantic classification cache for opened documents is never populated (written to the unopened-documents cache)対応中かも @xperiandri が 41 日前に担当しました。 オープンNeeds-Triage
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 3 日以内に返信
-
Needs-Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/fsharp#20265 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
Bug Needs-Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 3 日以内に返信
-
agentic-workflows
難易度 4/5 1〜2日 初心者へのやさしさ 15/100
メンテナーはふだん 3 日以内に返信
似ている issue
-
area: compat area: parsing bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
reubeno/brush#1526 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
FuRongJun-1999/dsh-memory#436 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信