简体   繁体   English

在Mono下运行的F#编译器中的堆栈溢出

[英]stack overflow in F# compiler running under mono

I'm updating the tooling for my project llvm-fs , so I installed the new version of mono and tried to compile it. 我正在更新项目llvm-fs的工具,因此我安装了新版本的mono并尝试对其进行编译。 Using either mono 3.10.0 with fsharpc 3.1 under OS X or mono 3.2.8 with fsharpc 3.0 under ubuntu the compile fails with a stack overflow: 在OS X下使用fsharpc 3.1 mono 3.10.0或在ubuntu下将fsharpc 3.0 mono 3.2.8结合使用时,编译失败并出现堆栈溢出:

Unhandled Exception:
System.StackOverflowException: The requested operation caused a stack overflow.
  at (wrapper managed-to-native) object:__icall_wrapper_mono_object_isinst (object,intptr)
  at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
  at Microsoft.FSharp.Compiler.Driver+DelayedDisposables.System-IDisposable-Dispose () [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Compiler.Driver.typecheckAndCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter, Microsoft.FSharp.Compiler.ErrorLoggerProvider errorLoggerProvider) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Compiler.Driver.mainCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Compiler.CommandLineMain.runMain (System.String[] argv) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Compiler.CommandLineMain.main (System.String[] argv) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.StackOverflowException: The requested operation caused a stack overflow.
  at (wrapper managed-to-native) object:__icall_wrapper_mono_object_isinst (object,intptr)
  at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
  at Microsoft.FSharp.Compiler.Driver+DelayedDisposables.System-IDisposable-Dispose () [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Compiler.Driver.typecheckAndCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter, Microsoft.FSharp.Compiler.ErrorLoggerProvider errorLoggerProvider) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Compiler.Driver.mainCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Compiler.CommandLineMain.runMain (System.String[] argv) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Compiler.CommandLineMain.main (System.String[] argv) [0x00000] in <filename unknown>:0 

You can reproduce this error on linux or OS X by doing the following: 您可以通过执行以下操作在Linux或OS X上重现此错误:

git clone git@github.com:fsprojects/llvm-fs.git
cd llvm-fs/
FSC=fsharpc ./build.bash

Under windows fsc 12.0.30815.0 the compile completes with no errors: 在Windows fsc 12.0.30815.0 ,编译完成,没有错误:

fsc --nologo --debug --sig:LLVMFSharp.fsi --target:library --out:LLVMFSharp.dll src/LLVM/FFIUtil.fs src/LLVM/Generated.fs src/LLVM/Core.fs src/LLVM/BitReader.fs src/LLVM/ExecutionEngine.fs src/LLVM/Extra.fs src/LLVM/Target.fs src/LLVM/Quote.fs

Is this a known issue and is there any way to work around it? 这是一个已知问题,是否有任何解决方法? I've tried passing different options to the mono runtime and none resulted in the compiler exiting normally. 我尝试将不同的选项传递给mono运行时,但没有一个导致编译器正常退出。 I do remember in the past mono has had some problems respecting tailcall instructions but I thought that those problems were mostly resolved. 我确实记得在过去,单声道在遵循尾调用指令时遇到了一些问题,但我认为这些问题已基本解决。 Thanks! 谢谢!

This is too long for a comment, but the error is triggered by this bit of code from generated.fs (in that commenting it out stops the stack overflow - there is an error later once this is commented out) (from line 6496-6506): 这对于注释来说太长了,但是错误是由generate.fs的这段代码触发的(因为注释掉它会停止堆栈溢出-注释掉以后会出现错误)(来自6496-6506行) ):

 [<DllImport(
            llvmAssemblyName,
            EntryPoint="LLVMRunFunction",
            CallingConvention=CallingConvention.Cdecl,
            CharSet=CharSet.Ansi)>]
        extern void* (* LLVMGenericValueRef *) runFunctionNative(
            void* (* LLVMExecutionEngineRef *) EE,
            void* (* LLVMValueRef *) F,
            uint32 NumArgs,
            void* (* LLVMGenericValueRef* *) Args)
        // I don't know how to generate an "F# friendly" version of LLVMRunFunction

The crash is occuring in the code that outputs the signature file. 在输出签名文件的代码中发生崩溃。

Disabling the signature file fixes the problem (but there is still an underlying bug somewhere). 禁用签名文件可以解决此问题(但是仍然存在某个潜在的错误)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM