Commit Graph
135 Commits
Author SHA1 Message Date
Ludovic Henry 916abe5f57 [bcl] Restore ThreadPool number of threads configuration after each test 2014-10-23 11:00:47 -04:00
Ludovic Henry a142d922aa [threadpool] Fix deadlock/starvation of the thread pool
The issue was with the new heuristic of the thread pool which would not create new threads, leading to deadlock between dependent tasks.
The fix is to check if every worker threads are sleeping, waiting or joining, and if that's the case, then we create a new thread because we might be in the case where the tasks being currently run depends on one still being enqueued in the cq or one of the wsq.

The following tests would previously fail :

1) MonoTests.System.Threading.Tasks.TaskTests.DoubleWaitTest :   #1
  Expected: True
  But was:  False

at MonoTests.System.Threading.Tasks.TaskTests.<DoubleWaitTest>m__27 () [0x00077] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:800
at MonoTests.System.Threading.Tasks.ParallelTestHelper.Repeat (System.Action action, Int32 numRun) [0x00007] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/ParallelTestHelper.cs:48
at MonoTests.System.Threading.Tasks.TaskTests.DoubleWaitTest () [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:790
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230

2) MonoTests.System.Threading.Tasks.TaskTests.HideSchedulerTest :   #1
  Expected: True
  But was:  False

at MonoTests.System.Threading.Tasks.TaskTests.HideSchedulerTest () [0x0003d] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:1914
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230

3) MonoTests.System.Threading.Tasks.TaskTests.WaitAll_TimeoutWithExceptionsAfter :   #1
  Expected: True
  But was:  False

at MonoTests.System.Threading.Tasks.TaskTests.WaitAll_TimeoutWithExceptionsAfter () [0x00070] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:317
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230

4) MonoTests.System.Threading.Tasks.TaskTests.WaitAll_TimeoutWithExceptionsBefore :   #1
  Expected: True
  But was:  False

at MonoTests.System.Threading.Tasks.TaskTests.WaitAll_TimeoutWithExceptionsBefore () [0x00070] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:341
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230

5) MonoTests.System.Threading.Tasks.TaskTests.WaitAnyTest :   #3
  Expected: not -1
  But was:  -1

at MonoTests.System.Threading.Tasks.TaskTests.<WaitAnyTest>m__0 () [0x00026] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:142
at MonoTests.System.Threading.Tasks.ParallelTestHelper.Repeat (System.Action action, Int32 numRun) [0x00007] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/ParallelTestHelper.cs:48
at MonoTests.System.Threading.Tasks.ParallelTestHelper.Repeat (System.Action action) [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/ParallelTestHelper.cs:42
at MonoTests.System.Threading.Tasks.TaskTests.WaitAnyTest () [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:128
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230

6) MonoTests.System.Threading.Tasks.TaskTests.WaitChildTestCase :   #0b
  Expected: True
  But was:  False

at MonoTests.System.Threading.Tasks.TaskTests.<WaitChildTestCase>m__25 () [0x0006d] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:705
at MonoTests.System.Threading.Tasks.ParallelTestHelper.Repeat (System.Action action, Int32 numRun) [0x00007] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/ParallelTestHelper.cs:48
at MonoTests.System.Threading.Tasks.TaskTests.WaitChildTestCase () [0x00000] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:684
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230

7) MonoTests.System.Threading.Tasks.TaskTests.WaitingForChildrenToComplete :   #3
  Expected: True
  But was:  False

at MonoTests.System.Threading.Tasks.TaskTests.WaitingForChildrenToComplete () [0x00048] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:734
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /Users/ludovic/Xamarin/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
2014-10-22 17:09:11 -04:00
Zoltan Varga bb86670c28 [bcl] Fix races in task tests. 2014-10-22 14:22:17 -04:00
Zoltan Varga 5a22dacd4e [bcl] Remove some verbose test output. 2014-10-06 14:56:32 -04:00
Marek Safar f39cc88e58 [corlib] Notify parent task when child task uses NotOnFaulted. Fixes #23594 2014-10-05 14:36:05 -04:00
Marek Safar ebcc2ee853 [corlib] Task never is CompletedSynchronously 2014-08-20 12:01:42 +02:00
Zoltan Varga 262ef7eb34 [bcl] Increase a timeout to fix a corlib+llvm test failure. 2014-07-17 23:15:49 +02:00
Zoltan Varga cd35ca1fe9 [bcl] Fix a race in a Task test. Fixes #20921. 2014-07-12 00:31:47 +02:00
Alex Rønne Petersen 4d59f61b23 Revert "[corlib] Re-enable TaskContinuationChainLeak test."
This reverts commit 265060cc22.

The test is still failing:

2) MonoTests.System.Threading.Tasks.TaskTests.TaskContinuationChainLeak :   Expected: False
  But was:  True

at MonoTests.System.Threading.Tasks.TaskTests+TaskContinuationChainLeakTester.Verify () [0x00000] in /var/lib/jenkins/workspace/Mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:1991
at MonoTests.System.Threading.Tasks.TaskTests.TaskContinuationChainLeak () [0x00022] in /var/lib/jenkins/workspace/Mono/mcs/class/corlib/Test/System.Threading.Tasks/TaskTest.cs:1948
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00054] in /var/lib/jenkins/workspace/Mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
2014-07-03 05:54:01 +02:00
Alex Rønne Petersen 265060cc22 [corlib] Re-enable TaskContinuationChainLeak test.
This is hopefully fixed after a57fb5b.
2014-07-01 21:53:56 +02:00
Alex Rønne Petersen 1633666e82 [corlib] Disable TaskContinuationChainLeak test on non-mobile too. 2014-06-23 14:11:40 +02:00
Marek Safar aad8d4924b [corlib] Disable test 2014-05-27 18:14:27 +02:00
Marek Safar a10df86558 [corlib] Better checks for release of parent task 2014-04-08 15:31:53 +02:00
BrandonLWhite 5e5f3a19fd Fixed memory leak in Task when child tasks are continually created.
This resolves bug # 18398 and other OOM scenarios in long running applications that make use of FromAsync, ContinueWith, etc. to "rearm" asynchronous operations.
2014-04-08 15:31:52 +02:00
Marek Safar c52a372c78 [corlib] Set test failure when test hangs 2014-04-07 19:22:17 +02:00
Rodrigo Kumpera 51d2b75664 [corlib] Fix 4.0 test suite compilation. 2014-02-12 18:53:10 -05:00
Marek Safar 1383b1834d [corlib] Better recovery when tasks run on broken scheduler 2014-02-06 18:08:37 +01:00
Marek Safar e83bf13866 [corlib] Mark all promise-style task exceptions observed. Fixes #17015 2014-01-06 17:52:19 +01:00
Marek Safar 395cf8f623 [corlib] Add check for launching cancelled task to all overloads 2013-12-07 19:51:35 +01:00
Marek Safar a2850fc7da Merge pull request #799 from kebby/master
Task.WhenAllCore<T> now handles empty argument list correctly. Fixes #15956
2013-11-12 00:38:48 -08:00
Tammo 'kb' Hinrichs a3bf4b4356 Added tests for Task.WhenAll w/ empty list 2013-11-06 15:55:32 +01:00
Alexander Köplinger 40eaa78a8d Fixed a test issue where net45 methods were used in net40 profile 2013-10-25 19:52:36 +02:00
Marek Safar cf2ac2171b Make Task.Delay more reliable. Fixes #14585 2013-10-08 10:16:19 +02:00
Marek Safar ee5939881d Fixed TaskFactory::ContinueWhenAny with func result. Fixes #14839 2013-09-20 19:41:15 +02:00
Marek Safar 20aaf27c90 Fixes scheduling of non-inlined sychronous continuations. 2013-07-16 10:00:15 +02:00
Marek Safar 8b7cf63dd3 Implement Task::AsyncWaitHandle. Fixes #12342 2013-05-23 11:11:25 +02:00
Marek Safar 146a289d36 Fix failing test 2013-02-18 11:48:39 +01:00
Marek Safar f0f4f4ae51 More mobile tests update 2013-02-14 13:06:49 +01:00
Marek Safar d6af35c68f Fix more mobile tests 2013-02-12 20:02:07 +01:00
Marek Safar c1437f237f Fix TaskCreationOptions.AttachedToParent to avoid NRE on TaskCreationOptions.DenyChildAttach and deadlock on Wait 2013-02-12 14:25:58 +01:00
Marek Safar 65518ad2ca RunSynchronously cannot be used with continuation 2013-02-12 14:25:58 +01:00
Rodrigo Kumpera 1b92a4148c Since MOBILE implies NET_4_* now, take this into account and simplify our ifdefs. 2013-02-11 18:42:18 -05:00
Marek Safar afa79435aa Update for mobile profile 2013-02-07 16:34:21 +01:00
Marek Safar d91bdcab02 Add new test 2013-01-18 15:30:53 +01:00
Jeremie Laval e7f4360ad3 [corlib] Fix unobserved exception being mistakenly propagated to finalizer thread when using ContinueWhenAll.
The problem was that we internally use Task.WhenAll inside TaskFactory.ContinueWhenAll to merge the given tasks into one that we can Continue on to run the passed arguments.

However, the behavior of WhenAll is to collect the exceptions that happened on its parent tasks and to set the aggregate on itself which was not catched by our continuation internally, leading to the exception remaining unobserved and escalating to the finalizer thread.
2012-11-15 15:01:32 +00:00
Martin Baulig e3bd9da840 Fix TaskFactory::FromAsync for methods that completed synchronously.
Don't call InnerInvoke() a 2nd time if the 'Begin' method that
completed synchronously already invoked the callback.
2012-10-25 21:55:33 +02:00
Zoltan Varga b5afc5a2ae Fix up class library test so they at least compile when running make check in runtime/. Add a 'test' target to compile them. 2012-10-18 16:02:19 +02:00
Marek Safar 7c3708d2ba Implement TaskFactory::FromAsync for calls completed synchronously. 2012-10-02 17:03:15 +01:00
Jeremie Laval 5877a9423b [corlib] Honor LazyCancellation flag 2012-09-24 12:28:25 +01:00
Jeremie Laval 2de1ee29c8 [corlib] Honor HideScheduler flag 2012-09-24 11:47:06 +01:00
Jeremie Laval 2ce078ba52 [corlib] Honor DenyChildAttach flag 2012-09-24 11:21:45 +01:00
Jeremie Laval 0b5eddeaff [corlib] Make Task.Run specify TaskScheduler.Default and fix Task.Run (Task<Task>) 2012-09-24 11:11:46 +01:00
Marek Safar f93ac4c461 Bump DoubleWaitTest timeout 2012-06-26 13:57:55 +01:00
Marek Safar c0b3d91a9a Improve task test 2012-06-11 12:11:35 +01:00
Marek Safar 8566a284a2 Update more 4.5 api 2012-06-08 11:44:55 +01:00
Jeremie Laval c0e097203a [corlib] Fix DoubleWait unit test 2012-06-01 13:22:42 +01:00
Marek Safar 455b845157 Fix scheduling of inlined tasks. 2012-05-30 12:08:08 +01:00
Marek Safar 1e3f458c21 Add another Task test 2012-05-29 16:13:45 +01:00
Marek Safar 46dacaa4cb Bump test timeout 2012-04-23 17:06:43 +01:00
Marek Safar 92c0b7cff2 Disable failing test 2012-04-23 17:02:32 +01:00