[Mono-dev] Stackoverflow exception while processing a linq query

Vladimir Dimitrov vlad.dimitrov at gmail.com
Sat Mar 2 19:37:00 UTC 2013


Recently I received a strange error on one of our servers which run mono 
2.10.8.1 on Ubuntu 12.4:

System.AggregateException: One or more errors occured ---> 
System.StackOverflowException: The requested operation caused a stack 
overflow.
   at 
System.Collections.Concurrent.SplitOrderedList`2[System.String,System.Collections.Generic.KeyValuePair`2[System.String,System.Collections.Generic.IEnumerable`1[Warehouse.Sync.Common.ChangeItem]]].GetParent 
(UInt32 v) [0x00000] in <filename unknown>:0
   at 
System.Collections.Concurrent.SplitOrderedList`2[System.String,System.Collections.Generic.KeyValuePair`2[System.String,System.Collections.Generic.IEnumerable`1[Warehouse.Sync.Common.ChangeItem]]].InitializeBucket 
(UInt32 b) [0x00000] in <filename unknown>:0
   at 
System.Collections.Concurrent.SplitOrderedList`2[System.String,System.Collections.Generic.KeyValuePair`2[System.String,System.Collections.Generic.IEnumerable`1[Warehouse.Sync.Common.ChangeItem]]].InitializeBucket 
(UInt32 b) [0x00000] in <filename unknown>:0
   at 
System.Collections.Concurrent.SplitOrderedList`2[System.String,System.Collections.Generic.KeyValuePair`2[System.String,System.Collections.Generic.IEnumerable`1[Warehouse.Sync.Common.ChangeItem]]].InitializeBucket 
(UInt32 b) [0x00000] in <filename unknown>:0

This continued in the logs for several megabytes. Looking at the code 
(https://github.com/mosa/Mono-Class-Libraries/blob/master/mcs/class/corlib/System.Collections.Concurrent/SplitOrderedList.cs) 
it looks perfectly normal to happen.

Looks like if InitializeBucket receives 0 then GetParrent will return 0. 
GetBucket can return null too if list it checks in is empty and then the 
whole thing gets into infinite recursion... Any idea on how this 
situation happens/can be avoided and if anybody else encountered a 
similar problem?

Thanks,
  Vladimir Dimitrov


More information about the Mono-devel-list mailing list