StackOverflowException on large lambda, or large entrypoint, crashing VS2015, or fsc.exe commandline #779
Labels
Bug
Impact-Medium
(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Reporting this separately, as it is unrelated to the issue where I first reported it: #758.
Cause
Large lambda or a large entrypoint may result in a StackOverflowException reported by
fsc.exe
, or a crash of Visual Studio 2015. In both cases, attaching a debugger "after the fact" fails. To see the actual exception, you must attach the debugger earlier.This may be a security issue, as it can bring down web sites that process F# code, or that use dynamic quotations.
Reproduction
To reproduce this issue, create any console application, in the
main argv
, copy the following lines approximately 400x (leading to a source file of some 800 lines). Depending on whether you rundevenv.exe
in safe mode or not, the actual crash may happen earlier or later:While it does matter what source code lines you use, these are the simplest lines I could come up with that causes this behavior. For instance, if you repeat the same line, or use structured code (i.e., many different, indented lines, variables etc), this error appears much later or not at all.
The crash occurs when the file is open. It doesn't always occur when it is auto-opened (single click), but always occurs when it is focus-opened (double-click in solution explorer).
Running
fsc.exe
from the command line also shows the same crash, though the number of lines is typically a bit higher (which makes sense, the stack is not eaten up by the Visual Studio environment).Reproducing example solution
A minimal reproducing example solution, including a full dump of the stack trace as it happened from
devenv.exe
: FSharpBug#779.zipAffected versions
I could reproduce the issue on:
More info
Head of the stack trace looks something like this:
My guess would be that the (recursive) code that walks the F# source lines, in some situations, does not get TCO'ed, which would explain why, on some different source code lines, the crash does not occur.
The text was updated successfully, but these errors were encountered: