Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#20,788 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 3 días

@T-Gro ya está trabajando en esto.

Desde el 16/10/2026.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
fsharp
Área
compilers

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Area-Quotations

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)
Lenguaje dominante
F#
Estrellas
4.3k
Forks
881
Merge medio
3 d 22 h
PR fusionados (30 d)
105

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dotnet/fsharp

Todos los issues de dotnet/fsharp

Issues similares

Más issues de Compilers

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.