Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Stack overflow when a quotation contains a list literal of about a thousand elements

オープン
#20,788 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 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 の本文から書いたものです。

説明

Bug Needs-Triage

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

  1. 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\"")
  1. Run dotnet fsi gen.fsx, then dotnet 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

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/fsharp のほかの issue

dotnet/fsharp の issue をすべて見る

似ている issue

Compilers の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。