[Moq] Multi-threaded scenarios sometimes failing...

276 views
Skip to first unread message

Jason Jarrett

unread,
May 10, 2010, 10:55:25 AM5/10/10
to moq...@googlegroups.com
Hello,

We recently had a dev check some code in that required he mock out our ITimeService and over the last week or so we've started to see some random failures. So this morning I dug a little deeper and was able to reproduce.

Below is the exception I was able to reproduce [IndexOutOfRangeException] 

(Note: You may have to run the test multiple times before receive the exception).

System.AggregateException : AggregateException_ctor_DefaultMessage
  ----> System.IndexOutOfRangeException : Index was outside the bounds of the array.
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeoutCancellationToken cancellationToken)
at System.Threading.Tasks.Parallel.ForWorker(Int32 fromInclusiveInt32 toExclusiveParallelOptions parallelOptionsAction`1 bodyAction`2 bodyWithStateFunc`4 bodyWithLocalFunc`1 localInitAction`1 localFinally)
at System.Threading.Tasks.Parallel.For(Int32 fromInclusiveInt32 toExclusiveAction`1 body)
at MyNamespace.MyClass.Should_Work() in OATestBase.cs: line 83
--IndexOutOfRangeException
at System.Collections.Generic.List`1.Add(T item)
at Moq.Interceptor.Intercept(ICallContext invocation)
at Moq.Proxy.CastleProxyFactory.Interceptor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.ITimeServiceProxy.get_Today()
at MyNamespace.MyClass.Somework() in OATestBase.cs: line 89
at MyNamespace.MyClass.<Should_Work>b__0(Int32 i) in OATestBase.cs: line 83
at System.Threading.Tasks.Parallel.<>c__DisplayClassf`1.<ForWorker>b__c()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
at System.Threading.Tasks.Task.<>c__DisplayClass3.<ExecuteSelfReplicating>b__2(Object

Here's how I repro'd the issue.

Other things to note.
1. I first started seeing this on an old version of Moq. So I upped to the latest and am still able to reproduce the issue.
2. Everything is .net 3.5 (My project, back-port of the System.Threading (reactive extensions), Moq, etc...)

Any thoughts?

--
Post: moq...@googlegroups.com
Unsubscribe: moqdisc-u...@googlegroups.com

Daniel Cazzulino

unread,
May 11, 2010, 9:19:31 AM5/11/10
to moq...@googlegroups.com
seems like a bug.

could you submit this as an Issue please? 

Thanks!

/kzu

--
Daniel Cazzulino | Developer Lead | XML MVP | Clarius Consulting | +1 425.329.3471

Jason Jarrett

unread,
May 11, 2010, 10:24:39 AM5/11/10
to moq...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages