Bug 3013 - infinite loop in concurrent ObjectPool class
Summary: infinite loop in concurrent ObjectPool class
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 2.10.x
Hardware: PC All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-01-23 07:28 UTC by Jonathan Shore
Modified: 2013-01-11 16:50 UTC (History)
2 users (show)

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

context diff (2.40 KB, application/octet-stream)
2012-01-23 07:28 UTC, Jonathan Shore

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:

Description Jonathan Shore 2012-01-23 07:28:15 UTC
Created attachment 1252 [details]
context diff

The internal class ObjectPool<T> in the System.Concurrent library has an infinite loop.  The loop occurs when 134217728 invocations of the Take() function have been called and a Release(obj) is subsequently called.  Due to using 0x8000000 to signal changing state this limitation of 134217728 Take/Release's exists.

The limitation is one thing, but there is a loop in Release() that has no "tries" like the outer loop, such that will loop forever in this scenario.

Find a patch enclosed (I tested in my own class, but could not build to test in-situ, so may be an error in the patch, please test).

I changed the code to use a long for the indexing with now 0x0800000000000000 as the signal bit.  I also added a "tries" to the inner loop so will never become infinite.  I suppose in the case of the new bit, this is not a real possibility.
Comment 1 Rodrigo Kumpera 2013-01-11 16:50:05 UTC
ObjectPool code was full of issues so we killed it.