-
Notifications
You must be signed in to change notification settings - Fork 7
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
Concurrency Bug #10
Comments
There are actually cares where it appears NClone gets stuck in an infinite loop. I'll try to create a minimal example to demonstrate the issue. I think both the NRE and infinite looping are related to the same issue of the internal dictionary not being thread-safe. I believe the issues are likely to arise when NClone is concurrently asked to clone the same type on different threads before the internal cache for that type has been fully constructed. |
The below program (tested targeting .NET Framework 4.5.2 with NClone version 1.1.1 from Nuget) consistently reproduces both the NRE and the infinite looping. The NRE happens almost every time, the infinite looping less often but still frequently enough to see the issue.
|
Fixes Issue #10 - NRE or infinite loop on concurrent cloning
Thank you for reporting and fixing this one! I'll try to release a new version today. |
NClone appears to have a concurrency bug.
I recently modified our test suite to run more tests in parallel, and since then I've been getting intermittent failures when cloning. This is using version 1.1.1 from Nuget.
So for example, i I have:
Then I will sometimes see the exception:
Result Message:
From the stacktrace, I suspect this bug is occurring because the replication strategy is caching per type, but using the non-threadsafe
System.Collections.Generic.Dictionary
. I suspect replacing with a thread-safe collection would resolve the issue.The text was updated successfully, but these errors were encountered: