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: WCF assemblies (show other bugs)
Version: 3.4.0
Hardware: Other Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-08-22 13:48 UTC by David Straw
Modified: 2017-09-06 16:55 UTC (History)
4 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

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 [MSFT] 2015-09-23 15:35:08 UTC
Applied patch.