-
-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solving Issue 249: Multi-threading issue - IndexOutOfRangeException #3
Solving Issue 249: Multi-threading issue - IndexOutOfRangeException #3
Conversation
Any chance that can be cleaned up so I can just merge the fix? |
I will try to fix. Problem was in the conditional references as far I remember, you confirm that the project this is the point that make you in troubles ?
|
The more isolated the change, the easiest for me to merge even from the website without having to even compile ;). |
Felice: did you get a chance to work this one out? It would be great to have your fix merged in! Thanks in advance. |
I need to learn using GIT, I did a mess last time. I think I had a chance to work on it Monday, but I need some help/advice from you or from someone else leading the project. Can you keep in touch? Felice Pollano http://www.felicepollano.comDa: "Daniel Cazzulino" notifications@github.com
|
Done! Felice Pollano http://www.felicepollano.comDa: "Daniel Cazzulino" notifications@github.com
|
Thanks a bunch for taking the time! The cause for add/remove "errors" is formatting most of the time. Moq uses /kzu Daniel Cazzulino On Mon, Sep 24, 2012 at 4:51 AM, Felice Pollano notifications@github.comwrote:
|
Yeah is the tab/spaces :(, Felice Pollano http://www.felicepollano.comDa: "Daniel Cazzulino" notifications@github.com
|
Do you know when this will be pushed to Nuget? We've just run into this issue today - it's amazing watching it get fixed in realtime! |
I hope soon. Is not up to me but up to Daniel or someon else leading the project. Felice Pollano http://www.felicepollano.comDa: "Harry McIntyre" notifications@github.com
|
We are also running into this issue and are looking forward to the fix being pushed to NuGet. |
Any update on when this will be pushed to NuGet? |
@lawrencejonston It is pushed in the Dev branch. |
It is pushed in the Dev branch. Felice Pollano http://www.felicepollano.comDa: "Lawrence Johnston" notifications@github.com
|
We are invoking a method on a mock object on several threads in parallel. When we try verifying the number of calls, it almost always blows up, with a null reference exception or out of range exception. Works fine, if the calls are in sequence. It appears, the code used by Moq to count the number of invocations is not thread-safe. It is also not clear if the above fix addresses this issue. If not, please let me know, so I can file a bug. Thanks, |
1 similar comment
We are invoking a method on a mock object on several threads in parallel. When we try verifying the number of calls, it almost always blows up, with a null reference exception or out of range exception. Works fine, if the calls are in sequence. It appears, the code used by Moq to count the number of invocations is not thread-safe. It is also not clear if the above fix addresses this issue. If not, please let me know, so I can file a bug. Thanks, |
This is solved in teh .Dev branch. You can download and compile. If even in this case you have the problem, please produce an unit test to show the behavior. Felice Pollano http://www.felicepollano.comFrom: "shsomash" notifications@github.com
|
Is this fix suppose to be available in the current nuget Moq 4.0.10827 ? |
No :( If anyone wants to contribute by automating the nuget generation, and then Thanks! /kzu from mobile
|
I tried the patch but I was still getting the same issue. While digging in the code, the racing codition pops a concurrent modification exception when looping through the InterceptStrategyContext.OrderedCalls in ExtractProxyCall#handle intercept (InterceptorStrategy.cs line 103). The access is well within the lock boundary of the Interceptor#intercept, but concurrently, the orderedCalls list is modified (add, delete) in the Interceptor#AddCall without being synchronized on the Mock. If I add lock(Mock) in the Interceptor#AddCall before either removing or adding the orderedCalls list, it fixes the issue. Frederic |
I would like to help. Felice Pollano http://www.felicepollano.comDa: "Daniel Cazzulino" notifications@github.com
|
@frederic If you can provide a test reproducing the problem, I will try to have a look at it. Felice Pollano http://www.felicepollano.comDa: "Frederic Tardif" notifications@github.com
|
Thanks Felice! We'd need a build.bat at the root of the source that produces the .nupkg. With that, we can then configure myget.org to clone&build on every commit With that in place, pushing a fix/feature to nuget.org is a matter of:
And everyone will always have a dev build package from dev by using the /kzu from mobile
|
We ran into the same issue and decided to build our own version from the DEV branch. Unfortunately this didn't work so well. We dont't have the NullReferenceException anymore, but instead we got a Deadlock now. I was able to reproduce the situation with a minimal test case: public class ClassToMock
{
AutoResetEvent reset = new AutoResetEvent(false);
public virtual void M1()
{
var task = new TaskFactory().StartNew(M2);
Thread.Sleep(500);
reset.Set();
task.Wait();
}
public virtual void M2()
{
reset.WaitOne();
}
}
[TestMethod]
public void TestMock()
{
var testMock = new Mock<ClassToMock>{CallBase = true};
testMock.Object.M1();
testMock.Verify(x => x.M1());
testMock.Verify(x => x.M2());
} This will block forever with the current DEV branch version. It this already known? Or do I miss something obvious here? |
@FelicePollano I'd be greateful if you could look into this issue :) |
This is the single commit to solve the issue 249 (on Google Code). There is as well an .gitihnore added and a removal of some conditional references to allow the test runs properly with XUnit gui.