Bug 6732 - BlockingCollection.TryTake(T%, Int32) ignores timeout
Summary: BlockingCollection.TryTake(T%, Int32) ignores timeout
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Jérémie Laval
Depends on:
Reported: 2012-08-29 05:00 UTC by phil
Modified: 2012-09-04 09:47 UTC (History)
2 users (show)

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:

Description phil 2012-08-29 05:00:56 UTC
When using Mono on Linux, the following unit test hangs because TryTake never returns even though we have provided a timeout:

        public void ReturnsNullOnDequeueTimeout()
            object o;
            BlockingCollection<object> _queue = new BlockingCollection<object>();
            bool success = _queue.TryTake(out o, 500);
            Assert.IsNull(o, "Object that was dequeued was not null.");
            Assert.IsFalse(success, "This should fail but it did not because there was something on the queue.");

The same test passes on a Windows machine not using Mono.

Here are details of machine we tested on:

$ uname -a
Linux hostname 2.6.18-128.7.1.el5 #1 SMP Wed Aug 19 04:00:49 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

And our mono version:

$ /usr/local/mono-2.10.9/bin/mono --version
Mono JIT compiler version 2.10.9 (tarball Tue Aug 28 16:56:12 BST 2012)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug 
        LLVM:          supported, not enabled.
        GC:            Included Boehm (with typed GC and Parallel Mark)

We observed the same behaviour with Mono v2.10.2.
Comment 1 Jérémie Laval 2012-09-04 09:47:41 UTC
Fixed in:
  - master: 516a087a4ccec138306f38b2986aebb6477e1d7b
  - mono-2-10: 85f30d851afd4a694fe13fc4ff9bc29b2fbdefc9

Thanks for the report.