This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 22307 - Intermittent IndexOutOfRangeException when opening/closing connections rapidly
Summary: Intermittent IndexOutOfRangeException when opening/closing connections rapidly
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.ServiceModel (show other bugs)
Version: 3.4.0
Hardware: Other Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-08-22 13:48 UTC by David Straw
Modified: 2015-09-23 15:35 UTC (History)
4 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description David Straw 2014-08-22 13:48:21 UTC
Our test suite ends up opening and closing HTTP connections in quick succession. On Mono we occasionally see an IndexOutOfRangeException involving ChannelDispatcher while running our tests. On other occasions we would see an ArgumentOutOfRangeException. Two of the stack traces we saw are below.

We fixed this by adding a lock around a call to RemoveChannel in ChannelDispatcher. I will submit a pull request with this fix.

Stack traces:
System.IndexOutOfRangeException: index < lower bound
  at System.Array.Clear (System.Array array, Int32 index, Int32 length) [0x0005b] in mono-3.4.0/mcs/class/corlib/System/Array.cs:886
  at System.Collections.Generic.List`1[System.ServiceModel.Channels.IChannel].Shift (Int32 start, Int32 delta) [0x0004a] in mono-3.4.0/mcs/class/corlib/System.Collections.Generic/List.cs:431
  at System.Collections.Generic.List`1[System.ServiceModel.Channels.IChannel].RemoveAt (Int32 index) [0x0001e] in mono-3.4.0/mcs/class/corlib/System.Collections.Generic/List.cs:562
  at System.Collections.Generic.List`1[System.ServiceModel.Channels.IChannel].Remove (IChannel item) [0x0000f] in mono-3.4.0/mcs/class/corlib/System.Collections.Generic/List.cs:524
  at System.ServiceModel.Dispatcher.ListenerLoopManager.RemoveChannel (IChannel ch) [0x00000] in mono-3.4.0/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:445
  at System.ServiceModel.Dispatcher.ListenerLoopManager+<ChannelAccepted>c__AnonStorey2.<>m__2 (System.Object , System.EventArgs ) [0x00031] in mono-3.4.0/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:534
  at (wrapper delegate-invoke) <Module>:invoke_void__this___object_EventArgs (object,System.EventArgs)
  at System.ServiceModel.Channels.CommunicationObject.OnClosed () [0x00012] in mono-3.4.0/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:223
  at System.ServiceModel.Channels.ChannelBase.OnClosed () [0x00000] in mono-3.4.0/mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChannelBase.cs:74
  at System.ServiceModel.Channels.CommunicationObject.ProcessClosed () [0x00011] in mono-3.4.0/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:209
  at System.ServiceModel.Channels.CommunicationObject.Close (TimeSpan timeout) [0x00023] in mono-3.4.0/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:141
  at System.ServiceModel.Channels.CommunicationObject.Close () [0x00000] in mono-3.4.0/mcs/class/System.ServiceModel/System.ServiceModel.Channels/CommunicationObject.cs:131
  at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x00027] in mono-3.4.0/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChannelDispatcher.cs:577


  System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
  at System.Collections.Generic.List`1[System.ServiceModel.Channels.IChannel].RemoveAt (Int32 index) [0x00000] in <filename unknown>:0
  at System.Collections.Generic.List`1[System.ServiceModel.Channels.IChannel].Remove (IChannel item) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Dispatcher.ListenerLoopManager.RemoveChannel (IChannel ch) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Dispatcher.ListenerLoopManager+<ChannelAccepted>c__AnonStorey2.<>m__2 (System.Object , System.EventArgs ) [0x00000] in <filename unknown>:0
  at (wrapper delegate-invoke) <Module>:invoke_void__this___object_EventArgs (object,System.EventArgs)
  at System.ServiceModel.Channels.CommunicationObject.OnClosed () [0x00000] in <filename unknown>:0
  at System.ServiceModel.Channels.ChannelBase.OnClosed () [0x00000] in <filename unknown>:0
  at System.ServiceModel.Channels.CommunicationObject.ProcessClosed () [0x00000] in <filename unknown>:0
  at System.ServiceModel.Channels.CommunicationObject.Close (TimeSpan timeout) [0x00000] in <filename unknown>:0
  at System.ServiceModel.Channels.CommunicationObject.Close () [0x00000] in <filename unknown>:0
  at System.ServiceModel.Dispatcher.ListenerLoopManager.TryReceiveRequestDone (IAsyncResult result) [0x00000] in <filename unknown>:0
Comment 1 Miguel de Icaza 2015-09-23 15:35:08 UTC
Applied patch.

Note You need to log in before you can comment on or make changes to this bug.