Bug 24270 - Children tasks return values
Summary: Children tasks return values
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
Depends on:
Reported: 2014-11-05 01:54 UTC by Yasser Mekled
Modified: 2014-11-10 11:19 UTC (History)
2 users (show)

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

two CSharp files compressed (510 bytes, application/gzip)
2014-11-05 01:54 UTC, Yasser Mekled

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 Yasser Mekled 2014-11-05 01:54:34 UTC
Created attachment 8628 [details]
two CSharp files compressed

the attached two samples are from "Exam Ref 80-483 Programming in C#".

the execution result should be (and tested under windows with .net 4.5.1):

but under Mono stable 3.10 from Xamarian Repo, running under XUbuntu 14.04.1
results always:
Comment 1 Marek Safar 2014-11-10 10:30:19 UTC
I am not sure what Exam Ref sample this are but they are wrong. The execution results are racy and you can get any of possible 4 combinations. You can modify the source code and add Thread.Sleep (5); before any of results[index] sets to simulate the race easier.
Comment 2 Yasser Mekled 2014-11-10 11:11:44 UTC
HI Marek,

How you analyzed the code?

It's not about racy condition at all. It's about 3 parallel tasks and parent wait for them all before continue.

if you run the same code under Windows without any modification, you will get the result as mentioned. Did you try it under windows?

not sure about Thread.Sleep(5); because it's about tasks not threads. it should be .wait(); and it's the last statement in the code.
Comment 3 Marek Safar 2014-11-10 11:19:51 UTC
It's racy, parent don't wait on them which can be easily tested when you do more than just simple assignment, e.g. Thread.Sleep