我用C#编写了一个程序。它使用F#maps。
程序运行正常,没有错误。但是,当我尝试用以下内容对其进行分析时:
mono --profile=log:report Program.exe
我收到以下错误:
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Object is not a Bar
at Test.Bar.CompareTo (System.Object obj) [0x00000] in <filename unknown>:0
at
Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericCompare$cont@923-1
(Microsoft.FSharp.Core.GenericComparer comp, System.Object yobj, System.Object xobj,
IComparable x, Microsoft.FSharp.Core.Unit unitVar) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericCompare
(Microsoft.FSharp.Core.GenericComparer comp, System.Object xobj, System.Object yobj)
[0x00000] in <filename unknown>:0
at
Microsoft.FSharp.Core.LanguagePrimitives
+HashCompare.GenericComparisonWithComparerIntrinsic[Bar]
(IComparer comp, Test.Bar x, Test.Bar y) [0x00000] in <filename unknown>:0
at
Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericComparisonIntrinsic[Bar]
(Test.Bar x, Test.Bar y) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Core.LanguagePrimitives+-cctor@2099-1[Test.Bar].Compare
(Test.Bar x, Test.Bar y) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Collections.MapTreeModule.add[Bar,Foo] (IComparer`1
comparer, Test.Bar k, Test.Foo v, Microsoft.FSharp.Collections.MapTree`2
m) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Collections.MapTreeModule.mkFromEnumerator[Bar,Foo]
(IComparer`1 comparer, Microsoft.FSharp.Collections.MapTree`2 acc, IEnumerator`1 e)
[0x00000] in <filename unknown>:0
at Microsoft.FSharp.Collections.MapTreeModule.ofSeq[Bar,Foo] (IComparer`1
comparer, IEnumerable`1 c) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Collections.FSharpMap`2[Test.Bar,Test.Foo]..ctor
(IEnumerable`1 elements) [0x00000] in <filename unknown>:0
似乎只有当我使用探查器运行程序时,才调用类Bar的方法CompareTo(object obj),其中某些东西似乎不是Bar。
该方法由以下方式实施:
public int CompareTo(object obj)
{
if (obj == null) return 1;
Bar otherBar = obj as Bar;
if (otherBar != null)
return this.CompareTo(otherBar);
else
throw new ArgumentException("Object is not a Bar!");
}
如上所述,如果没有分析,则不会发生此错误。
mono --version给出:
Mono JIT compiler version 2.10.5 (Debian 2.10.5-1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: Included Boehm (with typed GC and Parallel Mark)
更新
mono --profile=log:sample Program.exe
mono --profile=log:nocalls Program.exe
两个都工作。但是,我希望标准的分析器也可以工作。
这是Mono中的错误,还是我做错了什么?
答案 0 :(得分:1)
根据official page of F# for cross-platform packages,你应该使用Mono 2.10.9或更高版本。
所以首先尝试升级单声道。