Memory management Mono内存管理错误?

Memory management Mono内存管理错误?,memory-management,mono,nullreferenceexception,Memory Management,Mono,Nullreferenceexception,我有一个用C#/.NET4.5.2开发的程序,在Windows(7x64)上运行良好。该程序处理大量数据,因此仅为x64编译。我最大的输入数据集可以在具有16GB RAM的PC上处理 当我尝试在Ubuntu 16.04 LTS 64位上运行它时;安装了64 GB RAM,对于较小的数据集来说一切都很好,但我开始使用较大的数据集获得SIGSEGV信号。这些错误并不总是发生在同一位置,对于中等大小的数据集,它们有时根本不会发生 我升级了我的Mono版本,因此现在运行的是5.0.1.1: TLS:uu

我有一个用C#/.NET4.5.2开发的程序,在Windows(7x64)上运行良好。该程序处理大量数据,因此仅为x64编译。我最大的输入数据集可以在具有16GB RAM的PC上处理

当我尝试在Ubuntu 16.04 LTS 64位上运行它时;安装了64 GB RAM,对于较小的数据集来说一切都很好,但我开始使用较大的数据集获得SIGSEGV信号。这些错误并不总是发生在同一位置,对于中等大小的数据集,它们有时根本不会发生

我升级了我的Mono版本,因此现在运行的是5.0.1.1:

TLS:uu线程
SIGSEGV:altstack
通知:epoll
架构:amd64
禁用:无
杂项:软调试
LLVM:受支持,未启用。
GC:sgen(默认情况下并发)

升级将该错误替换为NullReferenceException:

本机堆栈跟踪:

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at (wrapper managed-to-native) System.Array:FastCopy (System.Array,int,System.Array,int,int)
  at System.Array.Copy (System.Array sourceArray, System.Int32 sourceIndex, System.Array destinationArray, System.Int32 destinationIndex, System.Int32 length) [0x00068] in <a07d6bf484a54da2861691df910339b1>:0 
  at System.Collections.Generic.HashSet`1[T].SetCapacity (System.Int32 newSize, System.Boolean forceNewHashCodes) [0x0000f] in <26aedeede9534b948c539f8734c8492d>:0 
  at System.Collections.Generic.HashSet`1[T].IncreaseCapacity () [0x00025] in <26aedeede9534b948c539f8734c8492d>:0 
  at System.Collections.Generic.HashSet`1[T].AddIfNotPresent (T value) [0x000bc] in <26aedeede9534b948c539f8734c8492d>:0 
  at System.Collections.Generic.HashSet`1[T].Add (T item) [0x00000] in <26aedeede9534b948c539f8734c8492d>:0 
  at MyLib.MyClass.DoProcessing () [0x00a6e] in <66a585adc1684679bfec565c73eb94e4>:0 
  at MyLib.MyClass.SynchProcessing () [0x00000] in <66a585adc1684679bfec565c73eb94e4>:0 
  at MyApp.Program.Main (System.String[] args) [0x00139] in <e80b0468d8e642129fa7c39d5b2bb0a0>:0 
未处理的异常:
System.NullReferenceException:对象引用未设置为对象的实例
at(包装器管理到本机)System.Array:FastCopy(System.Array,int,System.Array,int,int)
在System.Array.Copy处(System.Array sourceArray、System.Int32 sourceIndex、System.Array destinationArray、System.Int32 destinationIndex、System.Int32 length)[0x00068]输入:0
位于System.Collections.Generic.HashSet`1[T].SetCapacity(System.Int32 newSize,System.Boolean forceNewHashCodes)[0x0000f]中:0
在System.Collections.Generic.HashSet`1[T].IncreaseCapacity()[0x00025]中:0
位于System.Collections.Generic.HashSet`1[T].AddifyNotPresent(T值)[0x000bc]中:0
在System.Collections.Generic.HashSet`1[T].中添加(T项)[0x00000]到:0
在MyLib.MyClass.DoProcessing()[0x00a6e]中:0
在:0中的MyLib.MyClass.SynchProcessing()[0x00000]处
在:0中的MyApp.Program.Main(System.String[]args)[0x00139]处
除了HashSet之外,它有时还会出现在Dictionary中(其中Node是一个由两个float组成的小类),但无论哪种方式,当它试图添加一个元素时都会出现在System.Array:FastCopy中。旧版本的Mono在给出SIGSEGV时报告了相同的位置。错误发生在代码的单线程部分,其中数据正在读取和预处理(稍后是多线程的,但该代码尚未产生错误,可能是因为所有集合都已达到最大大小或正在缩小)

因此,当重新分配哈希集或字典的底层数组时,内部指针似乎已损坏

有人见过这样的东西吗?我认为这看起来像是内存管理器/垃圾收集器错误,甚至是Mono中的一个潜在错误?然而,搜索谷歌和这个网站并没有发现任何东西。我看到Mono有一个新的GC,但是Mono-V说它正在运行be default(而SIGSEGV是在使用旧版本时产生的)

有人有什么建议或解决方案可以尝试吗


我不知道发生此错误时堆和集合的大小。下一步,我将添加一些诊断来尝试和帮助,尽管它们会使速度变慢,并且只给出近似值(例如,Console.WriteLine每隔10000个节点)

可以确认我在mono 5.4.0.167上看到了相同的结果-除此之外,相同的
--版本
输出。在我的例子中,使用
HashSet
,NRE似乎出现在
AddIfNotPresent
中,但我认为该集不会很大。我还没有找到一个解决方案。我的中期解决方案可能是移植到.NETCore,但很可能是明年夏天。目前在Windows PC上运行最大的数据集,在Ubuntu box上运行其他数据集。我更喜欢后者,因为它由一个大脚本控制,我使用Windows PC for dev/etc!